A. Digit Game SOLUTION CODEFORCES

Digit Game SOLUTION

Everybody realizes that operators in Valorant conclude, who will play as aggressors, and who will play as safeguards. To do that Raze and Breach chose to play t matches of a digit game…
In every one of t matches of the digit game, a positive whole number is created. It comprises of n digits. The digits of this whole number are numerated from 1 to n from the most noteworthy request digit to the least request digit. After this whole number is reported, the match begins.
Operators play reciprocally. Level beginnings. In one turn a specialist can pick any plain digit and imprint it. Destroy can pick digits on odd positions, yet can not pick digits on even positions. Penetrate can pick digits on even positions, yet can not pick digits on odd positions. The match closes, when there is just a single plain digit left. In the event that the single last digit is odd, at that point Raze wins, else Breach wins.
It tends to be demonstrated, that before the finish of the counterpart (for each underlying number with n digits) every specialist has a capacity to make a turn, for example there is in any event one plain digit, that remains on a place of required equality.
For every one of t matches discover, which specialist wins, if them two need to win and play ideally.
Information
First line of information contains a whole number t (1≤t≤100) — the quantity of matches.
The principal line of each match portrayal contains a number n (1≤n≤103) — the quantity of digits of the produced number.
The second line of each match depiction contains a n-digit positive number without driving zeros.
Yield
For each match print 1, if Raze wins, and 2, if Breach wins.
Model
inputCopy
4
1
2
1
3
3
102
4
2069
outputCopy
2
1
1
2
Note
In the principal coordinate nobody can make a turn, the main digit left is 2, it’s even, so Breach wins.
In the second match the main digit left is 3, it’s odd, so Raze wins.
In the third match Raze can stamp the last digit, after that Breach can just check 0. 1 will be the last digit left, it’s odd, so Raze wins.
In the fourth match regardless of how Raze plays, Breach can check 9, and at long last there will be digit 0. It’s even, so Breach wins.

Related : 

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+