1297: Return of the Nim

内存限制:64 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:33 解决:16

题目描述

Sherlock and Watson are playing the following modified version of Nim game:

  • There arenpiles of stones denoted aspiles0,piles1,...,pilesn-1, andnis a prime number;
  • Sherlock always plays first, and Watson and he move in alternating turns. During each turn, the current player must perform either of the following two kinds of moves:
    1. Choose one pile and removek(k>0) stones from it;
    2. Removekstones from all piles, where 1≤kthesizeofthesmallestpile. This move becomes unavailable if any pile is empty.
  • Each player moves optimally, meaning they will not make a move that causes them to lose if there are still any better or winning moves.
Giving the initial situation of each game, you are required to figure out who will be the winner

输入


The first contains an integer,g, denoting the number of games. Thegsubsequent lines describe each game over two lines:
1. The first line contains a prime integer,
n, denoting the number of piles.
2. The second line contains
nspace-separated integers describing the respective values ofpiles0,piles1,...,pilesn-1.

  • 1≤g≤15
  • 2≤n≤30, wherenis a prime.
  • 1≤pilesi105where0≤in−1


输出

For each game, print the name of the winner on a new line (i.e., either “Sherlock”or “Watson”)

样例输入复制

2 3 2 3 2 2 2 1

样例输出复制

Sherlock Watson
Baidu
map