Little Deepu and his Girlfriend
Practice
3.4 (28 votes)
Algorithms
Approved
Dynamic programming
Game theory
Math
Medium
Open
Problem
51% Success 3716 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Little Deepu recently got a new job, so to celebrate, he decided to take his girfriend, Kate, out on a fancy candle light dinner.
To make things perfect for Kate, Deepu planned the night to the last detail. The food, the music, the ambience, everything was perfect, but stupidly enough Deepu forgot to get her a present.
After dinner, Kate asks our Deepu for her gift, when she finds out that he hasn't got her any she gets upset, to try smooth things with her, he proposes a game, this makes Kate so angry that she dumps him right there(bad move Deepu). Well its safe to say the rest of the evening was uneventful for Little Deepu but the game he proposed was pretty interesting.
To put the game a bit formally, we have two players Little Deepu and Kate and M items in the bag B, also we have a game set S with N elements, each element of game set is an integer. The game is played as follows, each player takes turn to pick an element from the game set S and removes that number of items from the bag, the player that is unable to remove the items from the bag looses the game. Little Deepu start the game ,If both Little Deepu and Kate play the game optimally, your task is to determine who wins the game.

Input:
First line contains a integer T , number of test cases. Each test case contain two lines , first line contain two integer M and N and second line contain elements of S.

Output:
For each test case print name of the winner of the game .

Constraints:
1 ≤ T ≤ 1000
1 ≤ M ≤ 10000
1 ≤ N ≤ 100
1 ≤ S[i] ≤ M

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingMediumOpen
Points:30
7 votes
Tags:
Ad-HocApprovedBasic ProgrammingBrute ForceDynamic ProgrammingMediumOpenSieve
Points:30
6 votes
Tags:
Introduction to Dynamic Programming 1AlgorithmsDynamic ProgrammingBinary Search
Editorial

No editorial available for this problem.