Note: To advance to the next rounds, you will need to score 25 points. Solving just this problem will not give you enough points.

Problem

Recently you went to a magic show. You were very impressed by one of the tricks, so you decided to try to figure out the secret behind it!

The magician starts by arranging 16 cards in a square grid: 4 rows of cards, with 4 cards in each row. Each card has a different number from 1 to 16 written on the side that is showing. Next, the magician asks a volunteer to choose a card, and to tell him which row that card is in.

Finally, the magician arranges the 16 cards in a square grid again, possibly in a different order. Once again, he asks the volunteer which row her card is in. With only the answers to these two questions, the magician then correctly determines which card the volunteer chose. Amazing, right?

You decide to write a program to help you understand the magician's technique. The program will be given the two arrangements of the cards, and the volunteer's answers to the two questions: the row number of the selected card in the first arrangement, and the row number of the selected card in the second arrangement. The rows are numbered 1 to 4 from top to bottom.

Your program should determine which card the volunteer chose; or if there is more than one card the volunteer might have chosen (the magician did a bad job); or if there's no card consistent with the volunteer's answers (the volunteer cheated).

Solving this problem

Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only 1 Small input. Once you have solved the Small input, you have finished solving this problem.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line containing an integer: the answer to the first question. The next 4 lines represent the first arrangement of the cards: each contains 4 integers, separated by a single space. The next line contains the answer to the second question, and the following four lines contain the second arrangement in the same format.

Output

For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1).

If there is a single card the volunteer could have chosen, y should be the number on the card. If there are multiple cards the volunteer could have chosen, y should be "Bad magician!", without the quotes. If there are no cards consistent with the volunteer's answers, y should be "Volunteer cheated!", without the quotes. The text needs to be exactly right, so consider copying/pasting it from here.

Limits

1 ≤ T ≤ 100.
1 ≤ both answers ≤ 4.
Each number from 1 to 16 will appear exactly once in each arrangement.

Sample

Input
Output

3
2
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
1 2 5 4
3 11 6 15
9 10 7 12
13 14 8 16
2
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
2
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
2
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Case #1: 7
Case #2: Bad magician!
Case #3: Volunteer cheated!

最新文章

  1. XML 动态 插入 父类标示 子类标示
  2. Docker: adding a file from a parent directory
  3. SharePoint 向多行文本类型字段插入特殊类型链接
  4. ie8及ie8以下支持html5 video标签
  5. 敏捷开发之Scrum扫盲篇(转)
  6. C#窗体的加载等待(BackgroundWorker控件)实现
  7. Object-C 基础笔记1--杂识
  8. wamp5 忘记mysql root密码 重置方法
  9. leetcode第一刷_Triangle
  10. winform 跨窗体给控件传值 分类: WinForm 2014-08-02 16:33 195人阅读 评论(0) 收藏
  11. JavaWeb:基于MVC设计模式的一个小案例(一)
  12. winform —— 连接数据库SQL Server 2008
  13. SuperSocket源码解析之配置系统
  14. Python逐块读取大文件行数的代码 - 为程序员服务
  15. jsp设置footer底部内容
  16. 关于UIView中相关坐标及改变的相关方法
  17. sudo 取消密码
  18. php const常量 不能使用字符串连接符.链接
  19. 【做题】agc006e - Rotate 3x3——分析&思维
  20. codeforces469B

热门文章

  1. sqlsever 和oracle的参数
  2. PHP switch的“高级”用法详解
  3. JAVA中使用freemark生成自定义文件(json、excel、yaml、txt)
  4. easyui 放大镜图标
  5. 去除自定义Toolbar中左边距
  6. linux selenium运行chrome
  7. 如何把自己的代码发布到npmjs(npm publish)
  8. 阿里蚂蚁的前端ant-design
  9. hdu 1283 最简单的计算机
  10. java gc log