There is a table of carrom game which has 4 sides. There are 4 players sitting on each side in the following order, A,B,C, and D.
The players sitting opposite to each other are in the same team. Therefore, A−C and B−D are the two teams.
There are N black pawns and N white pawns distributed in the table at different positions. And there is also one Red pawn.
The game goes as follows,
Now the task for the players is to hit the pawns. A−C team will always target Black Pawns and B−D will always target White Pawns. No one will target Red pawn. If all the N pawns assigned to that team are hit, then only they will pursue Red Pawn. Whoever successfully hits the red pawn wins the game.
For every turn, in which a player is unable to hit any pawn, his skill level would be incremented by one.
The turn of the players goes as follows:
A−B−C−D−A−B−...and so on
Here, A starts first.
Notes
You have to determine who will win the game considering each team plays optimally.
Input format
Output format
You have to print the string "A−C" if A−C team wins, else print "B−D" (without the quotes).
Constraints
0 < N ⩽ 5
0 ⩽ P, Q, R, S ⩽ 100
0 ⩽ Sum of the difficulty levels of black pawns ⩽ 10
0 ⩽ Sum of the difficulty levels of white pawns ⩽ 10
0 ⩽ Difficulty level of single red pawn ⩽ 105
The optimal strategy for B-D team would be that only either of B or D would be hitting all pawns so that the sum of White pawn i.e 24 would be added to either B or D leading it to make it atleast of Skill level 26. While an optimal strategy for A-B would lead them to maximum Skill level of 22. i.e player C hits all the black pawns. And if you would have noticed that either B/D after hitting a pawn of difficulty 2 they would end up with skill level of 4 but remaining pawns are of difficulty 10 & 12 so he would have to wait 6 rounds so that 4+6 (every round skill level increments by 1 of that player if no pawn is hit by that player). So after skill level of C becomes 10 he can hit 10 & 12 and total skill level becomes 10+10+12 = 32, while player B would end up 17 + 6 (of 6 rounds) = 21. After this red pawn is 100 difficult and C is 68 skills away while player B is 79 skills away so B hits after 68 rounds and ends up winning. So B-D team wins.