311083: CF1931E. Anna and the Valentine's Day Gift

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Anna and the Valentine's Day Gifttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Sasha gave Anna a list $a$ of $n$ 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 $a_i$ from the list and reverse the sequence of its digits. For example, if Anna chose the element with a value of $42$, it would become $24$; if Anna chose the element with a value of $1580$, it would become $851$. 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 $a_i$ and $a_j$ ($i \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 $2007$ and $19$, he would remove these two elements from the list and add the integer $200719$ or $192007$. After such a turn, the number of elements in the list decreases by $1$.

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 $10^m$ (i.e., $\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.

Input

The first line contains an integer $t$ ($1 \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 $n$, $m$ ($1 \le n \le 2 \cdot 10^5$, $0 \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 $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the list that Sasha gave to Anna.

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

Output

For each test case, output:

  • "Sasha", if Sasha wins with optimal play;
  • "Anna", if Anna wins with optimal play.
ExampleInput
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
Output
Sasha
Anna
Anna
Sasha
Sasha
Anna
Anna
Anna
Sasha
Note

Consider the first test case.

Anna can reverse the integer $2$, then Sasha can concatenate the integers $2$ and $14$, obtaining the integer $214$, which is greater than $10^2 = 100$. If Anna had reversed the integer $14$, Sasha would have concatenated the integers $41$ and $2$, obtaining the integer $412$, which is greater than $10^2 = 100$. Anna has no other possible moves, so she loses.

Output

题目大意:
题目描述了一个游戏,Sasha 和 Anna 交替进行操作,Anna 先手。游戏的目标是看最后剩下的数字是否大于等于 $10^m$。游戏规则如下:

1. Anna 可以选择列表中的一个整数 $a_i$,并将它的数字顺序颠倒。例如,如果选择了整数 42,它会变成 24;如果选择了整数 1580,它会变成 851。注意,前导零会被移除。操作后,列表中的元素数量不变。
2. Sasha 必须从列表中提取两个不同的元素 $a_i$ 和 $a_j$,并将它们按任意顺序连接后放回列表中。例如,如果选择了元素 2007 和 19,他会从列表中移除这两个元素,并添加整数 200719 或 192007。操作后,列表中的元素数量减少 1。

游戏在 Sasha 无法进行操作时结束,即 Anna 操作后列表中正好剩下一个数字。如果这个数字大于等于 $10^m$,Sasha 胜利;否则,Anna 胜利。

输入输出数据格式:
输入:
- 第一行包含一个整数 $t$($1 \le t \le 10^4$),表示测试用例的数量。
- 每个测试用例的描述如下:
- 第一行包含两个整数 $n$ 和 $m$($1 \le n \le 2 \cdot 10^5$,$0 \le m \le 2 \cdot 10^6$),分别表示列表中整数的数量和决定 Sasha 胜利的参数。
- 第二行包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$($1 \le a_i \le 10^9$),表示 Sasha 给 Anna 的列表。

输出:
- 对于每个测试用例,输出:
- 如果 Sasha 在最佳策略下获胜,输出 "Sasha"。
- 如果 Anna 在最佳策略下获胜,输出 "Anna"。题目大意: 题目描述了一个游戏,Sasha 和 Anna 交替进行操作,Anna 先手。游戏的目标是看最后剩下的数字是否大于等于 $10^m$。游戏规则如下: 1. Anna 可以选择列表中的一个整数 $a_i$,并将它的数字顺序颠倒。例如,如果选择了整数 42,它会变成 24;如果选择了整数 1580,它会变成 851。注意,前导零会被移除。操作后,列表中的元素数量不变。 2. Sasha 必须从列表中提取两个不同的元素 $a_i$ 和 $a_j$,并将它们按任意顺序连接后放回列表中。例如,如果选择了元素 2007 和 19,他会从列表中移除这两个元素,并添加整数 200719 或 192007。操作后,列表中的元素数量减少 1。 游戏在 Sasha 无法进行操作时结束,即 Anna 操作后列表中正好剩下一个数字。如果这个数字大于等于 $10^m$,Sasha 胜利;否则,Anna 胜利。 输入输出数据格式: 输入: - 第一行包含一个整数 $t$($1 \le t \le 10^4$),表示测试用例的数量。 - 每个测试用例的描述如下: - 第一行包含两个整数 $n$ 和 $m$($1 \le n \le 2 \cdot 10^5$,$0 \le m \le 2 \cdot 10^6$),分别表示列表中整数的数量和决定 Sasha 胜利的参数。 - 第二行包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$($1 \le a_i \le 10^9$),表示 Sasha 给 Anna 的列表。 输出: - 对于每个测试用例,输出: - 如果 Sasha 在最佳策略下获胜,输出 "Sasha"。 - 如果 Anna 在最佳策略下获胜,输出 "Anna"。

加入题单

上一题 下一题 算法标签: