ADAGAME - Ada and Game


Ada the Ladybug is playing Game of Digits against her friend Velvet Mite Vinit. The game is played in following manner: At first, there is a four-digit number and a number of moves. Both Ada and Vinit take turns alternately (beginning with Ada). Both of them must increase ANY digit of the number, but if the digit was 9 it will become 0.

For example number 3590 can be expanded to: 4590,3690,3500 or 3591. If after all turns the number is greater than the original number, Ada wins - otherwise Vinit is the winner. Both of them play optimally - can you decide who is the winner?

PS: It is possible, that Ada will have one more turn (if number of turns is odd)

Input

First line of input will consist T ≤ 200 number of test-cases. Each testcase will consist of four digit number 0 ≤ N < 104 [the original number] and 0 ≤ M ≤ 100 [the number of turns].

Output

For each test-case, print the name of winner ("Ada" or "Vinit").

Example Input

5
0000 0
5566 3
3333 10
9999 9
1234 30

Example Output

Vinit
Ada
Ada
Vinit
Ada

hide comments
wk1948: 2017-05-17 04:59:56

awsome problem

Last edit: 2017-05-17 05:15:11
shubham8_: 2017-05-14 23:29:22

I dont understand the time limit, I was using string and to convert it into int I was calling a function it was giving tle and when I wrote two for loop lines at the same place it got passed :(

morass: 2017-04-30 02:50:40

@muneebaadil: Good day to you - yes, any digit can be incremented:: 0084 can become {1084,0184,0094,0085}

Good Luck & Have Nice Day

muneebaadil: 2017-04-28 20:30:41

@morass, suppose we arrive at number 0084, can it become 1084 or 0184? Or most significant zeroes cannot be incremented? Kindly clarify, thanks.

piuspbd: 2017-03-27 00:37:54

Awesome!

sharma96: 2016-12-28 10:49:37

@morass , does this problem uses a known DP algorithm or it's just a logical question?

Last edit: 2016-12-28 19:20:33
morass: 2016-12-10 23:03:34

@kira28: That if there exists a move which leads to sure victory {if no mistake appear - and it won't appear} then the player will choose such move [i.e since none will make any mistake it is possible {for each state} to decide who will win]

kira28: 2016-12-10 17:27:58

@morass what does "both of them play optimally" stand for?

morass: 2016-12-10 15:45:29

@kira28: oh .. well hard to say... I can say that Vinit will win- there is nothing Ada can do about it ... an example of "how it can end" is by number "0593" - but since it doesn't matter for Ada what steps she will do, the result can be as well "3590"

kira28: 2016-12-10 14:36:03

@morass after all 5 turns.what will be that number which we will compare with the orignal number , to decide the winner


Added by:Morass
Date:2016-09-06
Time limit:4.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU