编程介的小学生 2017-04-06 15:13 采纳率: 0.2%
浏览 761
已采纳

Weekend Party

As the only Oni (a kind of fabulous creature with incredible strength and power) living on the surface of Gensokyo, Ibuki Suika has an interest in gathering Humans and Youkai in Gensokyo and holding party every day.

Today Suika has asked several friends to participate in a weekend party, which will be held at Hakurei Shrine as usual. Though Gensokyo was isolated from the outside world, everyone here is still a fan of ACG (Anime, Comic and Game). Of course, some people may only like parts of ACG. For example, Reimu likes Anime and Game, Marisa only likes Comic but Kaguya likes all of them.

TH_SuikasParty.jpg
In order to make everyone enjoy the party, Suika decide to arrange them into a circle so that everyone can have at least one common interest with both left and right hand side, which means one has at least a common interest with left AND has at least a common interest with right. By the way, Suika knows all her friends' interest. Please find out if she can get an arrangement of seats that satisfies the constraint described above.

Input

There are multiple test cases. For each test case:

The first line contains an integer N (1 <= N <= 64) indicates the number of girls in Gensokyo. Then followed by N lines, each line contains two strings Ai and Bi (each contains only alphanumeric characters). Ai represents the name of the i-th girl and the length of it will not exceed 10. Bi is a non-empty subset of "ACG".

Output

For each test case, output "Yes" if there exists at least one arrangement of seats, otherwise output "No".

Sample Input

1
Reimu AG
2
Reimu AG
Marisa C
3
Reimu AG
Marisa C
Kaguya GAC
Sample Output

Yes
No
No

  • 写回答

1条回答 默认 最新

  • devmiao 2017-04-06 16:12
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问GPT语言模型怎么训练?
  • ¥15 已知平面坐标系(非直角坐标系)内三个点的坐标,反求两坐标轴的夹角
  • ¥15 webots有问题,无响应
  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证