#P1500. 信息传递

信息传递

信息传递

题目描述

nn 位同学在操场上排列成一个圈,他们的编号分别为 0,1,2,...,n10,1,2,...,n-1,这意味着第 n1n-1 位同学的下一位是第 00 位同学。每个同学的手上会被发一个数字 aia_i,表示如果这名同学已经知晓信息,他可以将信息传递给他后方的第 aia_i 个人,即传递给第 (i+ai)modn(i + a_i) \bmod n 位同学。

作为游戏的发起者,你可以任意且不限次数的重新排列这些同学的位置,并且任意选择一个同学作为起点,开始传递信息。你的任务是,确定是否存在一种方法,能够让所有人都知晓信息。

输入格式

输入包含多测。 第一行为一个整数 TT,表示测试数据组数。 对于每组测试数据: 第一行为一个整数 nn,表示同学数量。 第二行为一个序列 aia_i,表示各个同学手上的数字。

数据范围

n105n \le 10^5 n106\sum n \le 10^6 ai{2,3}a_i \in \{2,3\}

输出格式

对于每组测试数据,若能完成任务,输出Yes,否则输出No

样例 #1

样例输入 #1

3
3
2 3 2
4
2 2 2 2
6
3 2 3 2 3 3

样例输出 #1

Yes
No
Yes

提示

For the first test case, no rearrangement is needed; simply choosing to tell the message to the first child achieves the goal.

For the second test case, it can be proven that the goal cannot be achieved.

For the third test case, by rearranging the sequence to 3 3 3 2 2 3 and telling the message to the child numbered 1, the goal can be achieved.