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}$.

Source: codechef | Difficulty: EASY
Tags: Ad-hoc


Solutions:
T = int(input())
for _ in range(T):
	same_state = False
	(n, k) = map(int, input().split())
	if k == 0:
		if n % 4 == 0:
			print('Off')
		else:
			print('On')
	elif n % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k == 0:
		if n % 4 == 0:
			print('Off')
		else:
			print('On')
	elif n % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b == 0:
		if a % 4 == 0:
			print('Off')
		else:
			print('On')
	elif a % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


for i in range(int(input())):
	(N, K) = [int(x) for x in input().split()]
	if K == 0:
		if N % 4 == 0:
			print('Off')
		else:
			print('On')
	elif N % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


t = int(input())
while t != 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if k == 0 and 0 < n % 4 < 4:
		print('On')
	elif n % 4 == 0:
		if k == 0:
			print('Off')
		else:
			print('On')
	else:
		print('Ambiguous')
	t -= 1


state = 0
s = 'On' if state == 1 else 'Off'
for i in range(int(input())):
	(a, b) = map(int, input().split())
	state = b
	if a == 0:
		print('On' if b == 1 else 'Off')
		continue
	if b == 0 and a % 4 == 0:
		print('Off')
		continue
	if b == 0 and a % 4 != 0:
		print('On')
		continue
	if b == 1 and a % 4 == 0:
		print('On')
		continue
	if b == 1 and a % 4 != 0:
		print('Ambiguous')


t = int(input(''))
for i in range(t):
	(N, K) = map(int, input().split())
	if K == 1:
		o = 0
		n = 0
		for i in range(1, 4):
			if (i + N) % 4 == 0:
				o = o + 1
			if (i + N) % 4 != 0:
				n = n + 1
		if n == 0:
			print('Off')
		if o == 0:
			print('On')
		else:
			print('Ambiguous')
	if K == 0:
		if N % 4 == 0:
			print('Off')
		else:
			print('On')


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().strip().split())
	s = n % 4
	if s == 0 and k == 0:
		print('Off')
	elif s == 0 and k == 1:
		print('On')
	elif s <= 3 and k == 0:
		print('On')
	else:
		print('Ambiguous')


for _ in range(int(input())):
	(change, state) = map(int, input().split())
	if change % 4 == 0 or change == 0:
		if state == 1:
			print('On')
		else:
			print('Off')
	elif state == 1:
		print('Ambiguous')
	elif state == 0 and (change % 4 == 1 or change % 4 == 2 or change % 4 == 3):
		print('On')
	else:
		print('Ambiguous')


t = int(input())
while t > 0:
	(x, y) = input().split()
	if int(y) == 0 and int(x) % 4 == 0:
		print('Off')
	elif int(y) == 1 and int(x) % 4 == 0:
		print('On')
	elif int(y) == 0 and int(x) % 4 != 0:
		print('On')
	else:
		print('Ambiguous')
	t = t - 1


tc = int(input())
for _ in range(tc):
	(changes, state) = map(int, input().split())
	if state == 0:
		if changes % 4 != 0:
			print('On')
		else:
			print('Off')
	elif changes % 4 != 0:
		print('Ambiguous')
	else:
		print('On')


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	if K == 0:
		if N % 4 == 0:
			print('Off')
		elif N % 4 != 0:
			print('On')
	elif K == 1:
		if N % 4 == 0:
			print('On')
		else:
			print('Ambiguous')


for t in range(int(input())):
	(level, state) = map(int, input().split())
	if state == 0:
		if level % 4 == 0:
			print('Off')
		else:
			print('On')
	if state == 1:
		if level % 4 == 0:
			print('On')
		else:
			print('Ambiguous')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n = n % 4
	if k == 1 and (n == 0 or n == 4):
		print('On')
	elif k == 1 and n != 0 and (n != 4):
		print('Ambiguous')
	elif k == 0 and n != 0 and (n != 4):
		print('On')
	elif k == 0 and (n == 4 or n == 0):
		print('Off')


def funcCall(N, K):
	if K == 0:
		if N % 4 == 0 or N == 0:
			return 'Off'
		else:
			return 'On'
	if N == 0:
		return 'On'
	else:
		setAmbg = []
		levelIndex = [1, 2, 3]
		for x in levelIndex:
			if (N + x) % 4 == 0:
				setAmbg.append(4)
			elif 4 in setAmbg:
				return 'Ambiguous'
		if len(setAmbg):
			return 'Ambiguous'
		return 'On'
T = int(input())
for _ in range(T):
	(N, K) = list(map(int, input().split()))
	print(funcCall(N, K))


for inputs in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 0:
		print('On') if n % 4 else print('Off')
	else:
		print('Ambiguous') if n % 4 else print('On')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if y == 0:
		if x % 4 == 0:
			print('Off')
		else:
			print('On')
	elif x % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


x = int(input())
for i in range(x):
	(n, k) = map(int, input().split())
	if k == 1:
		if n % 4 == 0:
			print('On')
		else:
			print('Ambiguous')
	if k == 0:
		if n % 4 == 0:
			print('Off')
		else:
			print('On')


for i in range(int(input())):
	(moves, state) = map(int, input().split())
	if state == 0:
		if moves % 4 == 0:
			print('Off')
		else:
			print('On')
	if state == 1:
		if moves % 4 == 0:
			print('On')
		else:
			print('Ambiguous')


n = int(input(''))
l = []
for i in range(n):
	a = str(input(''))
	m = a.split(' ')
	l += [m]
for i in l:
	a = int(i[0])
	b = int(i[1])
	if b == 1:
		if a % 4 == 0:
			print('On')
		else:
			print('Ambiguous')
	if b == 0:
		if a % 4 == 0:
			print('Off')
		else:
			print('On')


for x in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 0:
		if n % 4 == 0:
			print('Off')
		else:
			print('On')
	elif n == 0 or n % 4 == 0:
		print('On')
	else:
		print('Ambiguous')


T = int(input())
for i in range(0, T):
	(N, K) = map(int, input().split())
	if K == 1:
		if N % 4 == 0:
			print('On')
		else:
			print('Ambiguous')
	else:
		temp = N + K
		if temp % 4 == 0:
			print('Off')
		else:
			print('On')