Dark Light Solution | CodeChef Problem Solution 2022
Tonmoy has a special torch. The torch has levels numbered to and states ( and ). Levels and correspond to the state while level corresponds to the state.
The levels of the torch can be changed as:
- Level changes to level .
- Level changes to level .
- Level changes to level .
- Level changes to level .
Given the initial state as and the number of changes made in the levels as , find the final state of the torch. If the final state cannot be determined, print instead.
Input Format
- First line will contain , the number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, two integers - the number of changes made in the levels and initial state of the torch. Here, denotes state while denotes state.
Output Format
For each test case, output in a single line, the final state of the torch, i.e. or . If the final state cannot be determined, print instead.
You may print each character of the string in uppercase or lowercase (for example, the strings , , and will all be treated as identical).
Constraints
Sample Input 1
3
4 0
0 1
3 1
Sample Output 1
Off
On
Ambiguous
Explanation
Test Case : Initially, the torch is in state. Since only level corresponds to the state, the torch is at level initially. After changes, the final level would be . Level corresponds to the state. Hence, finally the torch is .
Test Case : Initially, the torch is in state. After changes, the torch remains in the state.
Test Case : Initially, the torch is in state. This can correspond to any of the first levels. Thus, we cannot determine the final level after changes. Hence, the final state is .
No comments:
Post a Comment