L - OOXX Game

本文介绍了一款特殊的游戏——OOXX游戏,并探讨了在最优策略下,两位玩家Fatbrother和Maze谁将赢得比赛。游戏在一个N*M的棋盘上进行,初始时棋盘上的每个格子为'O'或'X'。玩家轮流选择一个标记为'O'的格子并将其变为'X'。当所有格子都变成'X'时游戏结束。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, there are N*M coins in this board with two symbol “O” or “X”. Then they take turns to choose a grid with symbol “O” and change it into “X”. The game ends when all the symbols in the board are “X”, and the one who cannot play in his (her) turns loses the game. Fat brother and Maze like this kind of OOXX game very much and play it day and night. They don’t even need a little rest after each game!

Here's the problem: Who will win the game if both use the best strategy? You can assume that Maze always goes first.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains two integers N and M indicate the size of the board. Then goes N line, each line with M character shows the state of the board.

1 <= T <=100, 1 <= n <=100, 1 <= m <=100

Output

For each case, output the case number first, and then output the winner’s name, either Fat brother or Maze. See the sample input and output for more details.

Sample Input

3
1 4
OXXX
2 4
OOXX
OOXX
1 2
XX

Sample Output

Case 1: Maze
Case 2: Fat brother
Case 3: Fat brother

AC代码(输入的时候以串的形式输入(校赛时犯过这样的错误))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值