Limits 1s, 512 MB

Jan and Jami are playing a game. Initially they have a string (S) consisting of only uppercase letters with fixed length 3. For example, AAH or KSZ or KJH.

Jan and Jami make alternating moves: Jan makes the first move, Jami makes the second move, Jan makes the third one, and so on. During each move, the current player must choose a letter from the string (S) and replace it with any of the next three letters from the alphabet. For example, if at a certain move, S = AMS, (Reminder: the next three letters of A are B, C and D) then the current player can make it BMS or APS or AMT (Here total nine different changes are possible).

If a player fails to move, he loses. Both players play optimally. You have to determine the winner of the game.

Input

The first line of the input contains a single integer Q (1<=Q<=10000) - the number of the query. Each of the next Q lines contain a string S consisting of only uppercase letters with fixed length 3.

Output

For each query, if Jan wins the game, print "Jan" otherwise print "Jami" (without quotes).

Sample

InputOutput
4
ZZW
ZZZ
YYZ
XYZ 
Jan
Jami
Jami
Jan

For the last sample: XYZ. In the first move, Jan makes YYZ (ZYZ or XZZ isn’t optimal). In the second move, Jami makes YZZ or ZYZ. In the third one, Jan makes ZZZ. Finally, Jami fails to move. So, Jan wins the game.

Submit

Login to submit.

Contributors

Statistics

50% Solution Ratio
serotoninEarliest, Aug '20
abid1729Fastest, 0.0s
serotoninLightest, 131 kB
samdani333Shortest, 250B
Toph uses cookies. By continuing you agree to our Cookie Policy.