CF1419A.Digit Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play tt matches of a digit game...

In each of tt matches of the digit game, a positive integer is generated. It consists of nn digits. The digits of this integer are numerated from 11 to nn from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts.

Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins.

It can be proved, that before the end of the match (for every initial integer with nn digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity.

For each of tt matches find out, which agent wins, if both of them want to win and play optimally.

输入格式

First line of input contains an integer tt (1t100)(1 \le t \le 100) — the number of matches.

The first line of each match description contains an integer nn (1n103)(1 \le n \le 10^3) — the number of digits of the generated number.

The second line of each match description contains an nn -digit positive integer without leading zeros.

输出格式

For each match print 11 , if Raze wins, and 22 , if Breach wins.

输入输出样例

  • 输入#1

    4
    1
    2
    1
    3
    3
    102
    4
    2069

    输出#1

    2
    1
    1
    2

说明/提示

In the first match no one can make a turn, the only digit left is 22 , it's even, so Breach wins.

In the second match the only digit left is 33 , it's odd, so Raze wins.

In the third match Raze can mark the last digit, after that Breach can only mark 00 . 11 will be the last digit left, it's odd, so Raze wins.

In the fourth match no matter how Raze plays, Breach can mark 99 , and in the end there will be digit 00 . It's even, so Breach wins.

首页