编程介的小学生 2017-08-17 06:13 采纳率: 20.5%
浏览 797
已采纳

A Coin Game

Description

Harry and Sally have recently got addicted to a coin game. The game goes as follows.

The games uses a T × T grid board, each square in which is denoted by a pair of integers (x, y) between 1 and T (inclusive). Two players take turns to flip the coins. Each turn a player can choose four coins in the squares (x1, y1), (x1, y2), (x2, y1) and (x2, y2) (1 ≤ x1 < x2 ≤ T, 1 ≤ y1 < y2 ≤ T) to flip, as long as the coin in (x2, y2) will be turned from heads to tails. The player who cannot make a move loses.

After a sweet winning streak, Harry says to Sally, “Let’s have a bet! I’ll play first, and I’ll put heads in some squares and tails in some others of the board. You can decide whether the rest of coins shows heads or tails. I dare say you can’t beat me no matter how you put them.”

Given the squares in which Harry puts heads and those in which he puts tails, can you help Sally decide on the rest of coins so that she will win to teach the arrogant Harry a lesson? Assume that both Harry and Sally play optimally in the game.

Input

The input contains multiple test cases. Each test cases begins with a line containing two integers n1 and n2 (n1, n2 ≤ 200). The next n1 + n2 lines each contain a pair of integers (x, y) (1 ≤ x, y ≤ 100). For the first n1 pairs, Harry puts heads in the corresponding squares. Harry lets Sally decide on coins in the squares denoted by the rest n2 pairs and puts tails in other squares.

Output

For each test case, if Sally can win the game, print “Yes”, followed by n2 letters being either “H” (heads) or “T” (tails), showing one way (possibly among others) she put the coins. The output should be in the same order as the squares appear in the input. If Sally cannot win, just print “No”.

Sample Input

0 4
1 1
1 2
2 1
2 2
1 1
1 1
2 2
Sample Output

Yes
T
T
T
T
Yes
T

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-18 15:34
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)