Codeforces Round #814 (div.2) A.Chip Game

A.Chip Game

Burenka and Tonya are playing an old Buryat game with a chip on a board of 𝑛×𝑚 cells.

At the beginning of the game, the chip is located in the lower left corner of the board. In one move, the player can move the chip to the right or up by any odd number of cells (but you cannot move the chip both to the right and up in one move). The one who cannot make a move loses.

Burenka makes the first move, the players take turns. Burenka really wants to win the game, but she is too lazy to come up with a strategy, so you are invited to solve the difficult task of finding it. Name the winner of the game (it is believed that Burenka and Tonya are masters of playing with chips, so they always move in the optimal way).

Chip's starting cell is green, the only cell from which chip can't move is red. if the chip is in the yellow cell, then blue cells are all options to move the chip in one move.

Input

The first line contains one integer t𝑡 (1≤t≤10^{4}) — the number of test cases. The following is a description of the input data sets.

The only line of each test case contains two integers n𝑛 and m𝑚 (1≤𝑛,𝑚≤10^{9}) — the dimensions of the game board.

Output

For each test case print a single line — the name of the winner of the game ("Burenka" or "Tonya").

Example

input

6

1 1

1 4

5 6

2 2

6 3

999999999 1000000000

output

Tonya
Burenka
Burenka
Tonya
Burenka
Burenka

Note

In the first case, Burenka has no move, so Tonya wins.

In the second case, Burenka can move 3 cells to the right, after which Tony will not be able to make a move, which means that Burenka wins.

In the third case, Burenka can move 5 squares to the right. Then we can say that we have a game on a board of 1×5 cells, and Tonya is the first player. In such game the second player wins, so in the original one Burenka will win.

【思路分析】

博弈。水题。

​
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <algorithm>

#define i64 long long

using namespace std;

void solve() {
    i64 n, m;
    cin >> n >> m;
    if (n==1||m==1){
        if ((n*m)&1) cout << "Tonya" << endl;
        else cout<<"Burenka"<<endl;
        return;
    }
    if ((!(n & 1) && !(m & 1))||(n&1&&m&1)) {
        cout << "Tonya" << endl;
    } else cout << "Burenka" << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值