#🔒 Game theory

6 messages · Page 1 of 1 (latest)

winged swift
#

Hello ! I got this problem about game theory and i dont now how i can start it. Can you give me a hint or anything?

Sheep

Problem code: OWCE | Time: 0.10 s | Memory: 50 MB |

Juhasi Jędruś and Bartuś decided to spice up their evening sheep roundup with a game they invented. Each of them, with the help of their dog, can round up any number of sheep grazing in several groups in the pasture. Since they have one dog, they will take turns rounding up the sheep: first Jędruś, then Bartuś, then Jędruś again, and so on, until the last one is rounded up. The one who rounds up the last sheep loses because their friend can take the only bottle of orange soda, which is cooling in the stream.

Because the groups of sheep are spaced apart, any number of sheep can be rounded up in a single roundup (minimum one, maximum all), provided they belong to the same group. The order in which the groups are selected is arbitrary.

After a few changes, Jędruś took the bottle of orange soda from the stream, even though there were still a lot of sheep grazing in the meadow, because, as he said, he would get it regardless of what Bartuś did. Consider whether this is possible? Write a program that will determine which shepherd will win the game, assuming Jędruś always starts first and both are clever enough to take advantage of all the opportunities offered by the arrangement of sheep grazing in the meadow.

Input

The first line of input contains an integer C, denoting the number of data sets, 1 ≤ C ≤ 10. The next C lines contain integers denoting the number of sheep groups and their numbers. The first number in the line denotes the number of sheep groups N, 1 ≤ N ≤ 10, followed by N numbers ai, 1 ≤ ai ≤ 10000, for 1 ≤ i ≤ N denote the size of each group. Output

The output should contain single capital letters in C lines: J if Jędruś wins or B if Bartuś wins.

Example

For input data:

2
5
7
9
23
11
17
3
1
2
3

The correct answer is

J
B

stoic flicker
#

Have you tried playing with the problem a bit?

#

Get a piece of paper and try to play against yourself

winged swift
#

i know now

#

i read an articule about NIM game

hot foxBOT
#

🔒 Game theory