CF1931E.Anna and the Valentine's Day Gift

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Sasha gave Anna a list aa of nn integers for Valentine's Day. Anna doesn't need this list, so she suggests destroying it by playing a game.

Players take turns. Sasha is a gentleman, so he gives Anna the right to make the first move.

  • On her turn, Anna must choose an element aia_i from the list and reverse the sequence of its digits. For example, if Anna chose the element with a value of 4242 , it would become 2424 ; if Anna chose the element with a value of 15801580 , it would become 851851 . Note that leading zeros are removed. After such a turn, the number of elements in the list does not change.
  • On his turn, Sasha must extract two elements aia_i and aja_j ( iji \ne j ) from the list, concatenate them in any order and insert the result back into the list. For example, if Sasha chose the elements equal to 20072007 and 1919 , he would remove these two elements from the list and add the integer 200719200719 or 192007192007 . After such a turn, the number of elements in the list decreases by 11 .

Players can't skip turns. The game ends when Sasha can't make a move, i.e. after Anna's move there is exactly one number left in the list. If this integer is not less than 10m10^m (i.e., 10m\ge 10^m ), Sasha wins. Otherwise, Anna wins.

It can be shown that the game will always end. Determine who will win if both players play optimally.

输入格式

The first line contains an integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

Then follows the description of the test cases.

The first line of each test case contains integers nn , mm ( 1n21051 \le n \le 2 \cdot 10^5 , 0m21060 \le m \le 2 \cdot 10^6 ) — the number of integers in the list and the parameter determining when Sasha wins.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1091 \le a_i \le 10^9 ) — the list that Sasha gave to Anna.

It is guaranteed that the sum of nn for all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, output:

  • "Sasha", if Sasha wins with optimal play;
  • "Anna", if Anna wins with optimal play.

输入输出样例

  • 输入#1

    9
    2 2
    14 2
    3 5
    9 56 1
    4 10
    1 2007 800 1580
    4 5
    5000 123 30 4
    10 10
    6 4 6 2 3 1 10 9 10 7
    1 1
    6
    1 1
    10
    8 9
    1 2 9 10 10 2 10 2
    4 5
    10 10 10 10

    输出#1

    Sasha
    Anna
    Anna
    Sasha
    Sasha
    Anna
    Anna
    Anna
    Sasha

说明/提示

Consider the first test case.

Anna can reverse the integer 22 , then Sasha can concatenate the integers 22 and 1414 , obtaining the integer 214214 , which is greater than 102=10010^2 = 100 . If Anna had reversed the integer 1414 , Sasha would have concatenated the integers 4141 and 22 , obtaining the integer 412412 , which is greater than 102=10010^2 = 100 . Anna has no other possible moves, so she loses.

首页