{"id":"84802221-63c0-45a0-8211-cab3553f947d","name":"Number Game","description":"Alice and Bob play a game.\r\n\r\nThey start with a number n and play in turns. In each turn, a player can make any one of the following moves:\r\n1. Divide n by any of its odd divisors greater than 1.\r\n2. Subtract 1 from n if n is greater than 1.\r\n\r\n\r\nDivisors of a number include the number itself.\r\nThe player who is unable to make a move loses the game.\r\nAlice moves first. Determine the winner of the game if both of them play optimally.","inputFormat":"The first line contains integer t, no. of test cases.\r\nEach of next t lines contain a number n.","outputFormat":"Print the winner ALICE or BOB.","constraints":"1<= t <= 100\r\n1<= n <= 10^9","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\nimport java.math.*;\r\n\r\npublic class Main {\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n\r\n }\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"7\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n12\r\n","sampleOutput":"BOB\r\nALICE\r\nALICE\r\nBOB\r\nALICE\r\nBOB\r\nALICE\r\n\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"2ad5b04e-e941-400c-906f-c74f902a71bd","name":"Number Game","slug":"number-game","type":1}],"next":{"id":"b382288b-05ac-40da-a798-e4377a3b01d1","name":"Game On Leaves","type":1,"slug":"game-on-leaves"},"prev":{"id":"907e8e95-4e3d-42f0-a0f0-ed129a6f7864","name":"Winner In Nim Game","type":1,"slug":"winner-in-nim-game"}}}

Number Game

Alice and Bob play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: 1. Divide n by any of its odd divisors greater than 1. 2. Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Alice moves first. Determine the winner of the game if both of them play optimally.

{"id":"84802221-63c0-45a0-8211-cab3553f947d","name":"Number Game","description":"Alice and Bob play a game.\r\n\r\nThey start with a number n and play in turns. In each turn, a player can make any one of the following moves:\r\n1. Divide n by any of its odd divisors greater than 1.\r\n2. Subtract 1 from n if n is greater than 1.\r\n\r\n\r\nDivisors of a number include the number itself.\r\nThe player who is unable to make a move loses the game.\r\nAlice moves first. Determine the winner of the game if both of them play optimally.","inputFormat":"The first line contains integer t, no. of test cases.\r\nEach of next t lines contain a number n.","outputFormat":"Print the winner ALICE or BOB.","constraints":"1<= t <= 100\r\n1<= n <= 10^9","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\nimport java.math.*;\r\n\r\npublic class Main {\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n\r\n }\r\n}\r\n"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"7\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n12\r\n","sampleOutput":"BOB\r\nALICE\r\nALICE\r\nBOB\r\nALICE\r\nBOB\r\nALICE\r\n\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"2ad5b04e-e941-400c-906f-c74f902a71bd","name":"Number Game","slug":"number-game","type":1}],"next":{"id":"b382288b-05ac-40da-a798-e4377a3b01d1","name":"Game On Leaves","type":1,"slug":"game-on-leaves"},"prev":{"id":"907e8e95-4e3d-42f0-a0f0-ed129a6f7864","name":"Winner In Nim Game","type":1,"slug":"winner-in-nim-game"}}}
plane

Editor


Loading...

Number Game

hard

Alice and Bob play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: 1. Divide n by any of its odd divisors greater than 1. 2. Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Alice moves first. Determine the winner of the game if both of them play optimally.

Constraints

1<= t <= 100 1<= n <= 10^9

Format

Input

The first line contains integer t, no. of test cases. Each of next t lines contain a number n.

Output

Print the winner ALICE or BOB.

Example

Sample Input

7 1 2 3 4 5 6 12

Sample Output

BOB ALICE ALICE BOB ALICE BOB ALICE

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode