P17542 [CodeChef] DARLIG
普及-
题目描述

Tonmoy has a special torch. The torch has 4 levels numbered 1 to 4 and $2 states (\texttt{On}$ and $\texttt{Off}). Levels 1, 2$, and 3 correspond to the $\texttt{On}$ state while level 4 corresponds to the $\texttt{Off}$ state.

The levels of the torch can be changed as:
Level 1 changes to level 2.
Level 2 changes to level 3.
Level 3 changes to level 4.
Level 4 changes to level 1.

Given the initial state as K and the number of changes made in the levels as N, find the final state of the torch. If the final state cannot be determined, print $\texttt{Ambiguous}$ instead.

------ Input Format ------

  • First line will contain T, the number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, two integers N, K - the number of changes made in the levels and initial state of the torch. Here, $K = 0 denotes \texttt{Off}$ state while $K = 1 denotes \texttt{On}$ state.

------ Output Format ------

For each test case, output in a single line, the final state of the torch, $i.e. \texttt{On}$ or $\texttt{Off}$. If the final state cannot be determined, print $\texttt{Ambiguous}$ instead.

You may print each character of the string in uppercase or lowercase (for example, the strings $\texttt{On}, \texttt{ON}, \texttt{on}$ and $\texttt{oN}$ will all be treated as identical).

------ Constraints ------

$1 ≤ T ≤ 10^{5}$
$0 ≤ N ≤ 10^{9}$
$0 ≤ K ≤ 1$

----- Sample Input 1 ------
3
4 0
0 1
3 1
----- Sample Output 1 ------
Off
On
Ambiguous
----- explanation 1 ------
Test Case $1$: Initially, the torch is in $\texttt{Off}$ state. Since only level $4$ corresponds to the $\texttt{Off}$ state, the torch is at level $4$ initially. After $4$ changes, the final level would be $4$. Level $4$ corresponds to the $\texttt{Off}$ state. Hence, finally the torch is $\texttt{Off}$.

Test Case $2$: Initially, the torch is in $\texttt{On}$ state. After $0$ changes, the torch remains in the $\texttt{On}$ state.

Test Case $3$: Initially, the torch is in $\texttt{On}$ state. This can correspond to any of the first $3$ levels. Thus, we cannot determine the final level after $3$ changes. Hence, the final state is $\texttt{Ambiguous}$.

输入格式

见题面

输出格式

见题面

样例输入
3 4 0 0 1 3 1
样例输出
Off On Ambiguous