Problem:
Problem G: Double or Increment
Problem
ある日、mo3tthi君とtubuann君は、魔法のポケットとビスケットを使ってゲームをすることにしました。
今ここに $K$ 個のポケットがあり、$1,2, \ldots ,K$ の番号がついています。
$i$ 番目のポケットの容量は $M_i$ で、最初 $N_i$ 枚のビスケットが入っています。
mo3tthi君とtubuann君は、mo3tthi君から始めて、以下の一連の操作を交互に行います。
ポケットを一つ選ぶ。
以下のいずれか一方の操作を一度だけ行う。ただし、操作の結果選んだポケットに入っているビスケットの枚数がポケットの容量を超える場合、操作を行うことはできない。
選んだポケットを撫でる。魔法の力によって選んだポケットに入っているビスケットの枚数が $1$ 増える。
選んだポケットを叩く。魔法の力によって選んだポケットに入っているビスケットの枚数が $2$ 倍になる。
操作を行えなくなった時点でゲームは終了し、操作を行えなくなった人が負け、そうでない人が勝ちになります。
mo3tthi君の友人であるあなたは、mo3tthi君から事前にこのゲームに勝てるかどうかを判定できないか相談されました。
mo3tthi君のために、mo3tthi君がこのゲームに必ず勝つことができるかどうかを判定するプログラムを作ってください。
Input
入力は以下の形式で与えられる。
$K$
$N_1$ $M_1$
$\vdots$
$N_K$ $M_K$
Constraints
入力は以下の条件を満たす。
$1 \leq K \leq 10^5$
$1 \leq N_i \leq M_i \leq 10^{18}$
入力は全て整数である
Output
mo3tthi君が最適に行動したとき、必ず勝つことができるなら"mo3tthi"を、そうでないなら"tubuann"を一行に出力する。
Sample Input 1
1
2 4
Sample Output 1
mo3tthi
mo3tthi君が一番目のポケットを叩くと、一番目のポケットに入っているビスケットの枚数が $4$ になり、tubuann君は操作を行うことができない。
Sample Input 2
2
2 3
3 8
Sample Output 2
tubuann
Sample Input 3
10
2 8
5 9
7 20
8 41
23 48
90 112
4 5
7 7
2344 8923
1 29
Sample Output 3
mo3tthi

Submitted solutions:

code_snippet: // AOJ #3070
// Double or Increment 2025.1.25

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int mex2(int a, int b) {
    bool used[3] = {false, false, false};
    used[a] = true;
    used[b] = true;
    for(int g = 0; g < 3; g++){
        if(!used[g]) return g;
    }
    return 3; 
}

void shrinkCapacity(ll &r, int &gEven, int &gOdd) {
    ll nr = r >> 1;
    int oldEven = gEven;
    int oldOdd  = gOdd;

    int x = (int)(nr & 1);
    int y = (int)((nr + 1) & 1LL); // y= (nr+1)%2
    int oldY = (y==0 ? oldEven : oldOdd);
    
    int newGx;
    if (x == 0) newGx = mex2(oldEven, oldOdd);
    else        newGx = (oldEven == 0);

    int newGxXor1 = mex2(oldEven, newGx);
    int newEven, newOdd;
    if (x == 0) {
        newEven = newGx;
        newOdd  = newGxXor1;
    } else {
        newEven = newGxXor1;
        newOdd  = newGx;
    }
    r = nr;
    gEven = newEven;
    gOdd  = newOdd;
}

int solvePocket(ll N, ll r){
    int gEven = (int)(r & 1);
    int gOdd  = gEven ^ 1;  // 0→1, 1→0

    while(!((r>>1) < N && N <= r)) shrinkCapacity(r, gEven, gOdd);
    return (N & 1)? gOdd: gEven;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int K;
    cin >> K;

    int nim = 0;  // Nim 和 (XOR) を貯める
    for(int i=0; i<K; i++){
        ll N, M;
        cin >> N >> M;
        nim ^= solvePocket(N, M);
    }
    if(nim == 0) cout << "tubuann" << endl;
    else         cout << "mo3tthi" << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3456
final_rank: 5

code_snippet: // AOJ #3070
// Double or Increment 2025.1.25

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#include <bits/stdc++.h>
using namespace std;

inline int mex2(int a, int b) {
    bool used[3] = {false, false, false};
    used[a] = true;
    used[b] = true;
    for(int g = 0; g < 3; g++){
        if(!used[g]) return g;
    }
    return 3; 
}

inline void shrinkCapacity(ll &r, int &gEven, int &gOdd) {
    ll nr = r >> 1;
    int oldEven = gEven;
    int oldOdd  = gOdd;

    int x = (int)(nr & 1);
    int y = (int)((nr + 1) & 1LL); // y= (nr+1)%2
    int oldY = (y==0 ? oldEven : oldOdd);
    
    int newGx;
    if (x == 0) newGx = mex2(oldEven, oldOdd);
    else        newGx = (oldEven == 0);

    int newGxXor1 = mex2(oldEven, newGx);
    int newEven, newOdd;
    if (x == 0) {
        newEven = newGx;
        newOdd  = newGxXor1;
    } else {
        newEven = newGxXor1;
        newOdd  = newGx;
    }
    r = nr;
    gEven = newEven;
    gOdd  = newOdd;
}

int solvePocket(ll N, ll r){
    int gEven = (int)(r & 1);
    int gOdd  = gEven ^ 1;  // 0→1, 1→0

    while(!((r>>1) < N && N <= r)) shrinkCapacity(r, gEven, gOdd);
    return (N & 1)? gOdd: gEven;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int K;
    cin >> K;

    int nim = 0;  // Nim 和 (XOR) を貯める
    for(int i=0; i<K; i++){
        ll N, M;
        cin >> N >> M;
        nim ^= solvePocket(N, M);
    }
    if(nim == 0) cout << "tubuann" << endl;
    else         cout << "mo3tthi" << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3496
final_rank: 6

code_snippet: // AOJ #3070
// Double or Increment 2025.1.25

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// mex を求める小関数 (0,1,2 だけあれば十分)
int mex2(int x, int y) {
    bool used[3]; 
    used[0] = used[1] = used[2] = false;
    used[x] = true;
    used[y] = true;
    for(int g=0; g<3; g++) {
        if(!used[g]) return g;
    }
    // 実際にはここに来ないはず
    return 3; 
}

// n, M を与えられたときの Grundy 数 g(n,M) を返す関数
// memo は n -> g(n) のメモ (ただし M 固定)．unordered_map<ll,int> などで十分
ll M;
unordered_map<ll,int> memo;

int grundy(ll n) {
    // 容量を超えたら遷移不可能扱いだが，実際呼ばない前提にする
    if(n > M) return 0;
    // "容量の半分を超えていたら +1 しかできず，Grundy は (M-n)%2" という簡単な式
    ll half = M/2;
    if(n > half) return (int)((M - n) & 1LL); 
    auto it = memo.find(n);
    if(it != memo.end()) return it->second;

    int g1;
    if(n+1 > half) g1 = (int)((M - (n+1)) & 1LL);
    else           g1 = grundy(n+1);

    int g2;
    ll dn = n << 1;  // 2n
    if(dn > half)  g2 = (int)((M - dn) & 1LL);
    else           g2 = grundy(dn);

    int g = mex2(g1, g2);
    memo[n] = g;
    return g;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int K;
    cin >> K;

    ll nim = 0; // 全部の g(N_i,M_i) を XOR していく

    for(int i=0; i<K; i++){
        ll N, M_i;
        cin >> N >> M_i;
        M = M_i;
        memo.clear(); // ポケットごとにメモリをクリア
        nim ^= grundy(N);
    }
    if(nim) cout << "mo3tthi" << endl;
    else    cout << "tubuann" << endl;
    return 0;
}
accuracy: 0.58
time_ms: 210
memory_kb: 7288
final_rank: 15

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll grundy(ll first,ll limit){

	ll right = limit;
	ll left;

	ll GU,KI;

	if(right%2 == 0){

		left = right/2+1;

		GU = 0;
		KI = 1;

	}else{

		left = (right+1)/2;

		GU = 1;
		KI = 0;
	}

	ll next_right,next_left;
	ll next_GU,next_KI;

	while(true){

		if(left <= first && right >= first){

			if(first%2 == 0){

				return GU;
			}else{

				return KI;
			}
		}

		next_right = left-1;
		if(next_right%2 == 0){

			next_left = (next_right/2)+1;
		}else{

			next_left = (next_right+1)/2;
		}

		bool work[3];
		for(int i = 0; i < 3; i++){

			work[i] = false;
		}

		//右端のgrundy計算
		if(next_right%2 == 1){

			work[GU] = true;
		}else{

			work[GU] = true;
			work[KI] = true;
		}

		int tmp_r;
		for(int i = 0; i < 3; i++){

			if(!work[i]){

				tmp_r = i;
				break;
			}
		}

		bool next[3];
		for(int i = 0; i < 3; i++){

			next[i] = false;
		}
		next[tmp_r] = true;
		next[GU] = true;

		int tmp_next;
		for(int i = 0; i < 3; i++){

			if(!next[i]){

				tmp_next = i;
				break;
			}
		}

		if(next_right%2 == 0){

			GU = tmp_r;
			KI = tmp_next;

		}else{

			GU = tmp_next;
			KI = tmp_r;
		}

		right = next_right;
		left = next_left;
	}
}


int main(){

	ll K;
	scanf("%lld",&K);

	ll XOR = 0;

	ll first,limit;

	for(ll loop = 0; loop < K; loop++){

		scanf("%lld %lld",&first,&limit);
		XOR ^= grundy(first,limit);
	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}


	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3164
final_rank: 2

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll grundy(ll first,ll maxi){

	bool used[3],used2[3];
	ll pre_GU,pre_KI;

	ll right = maxi,left = maxi/2+1;
	if(right%2 == 0){

		pre_GU = 0;
		pre_KI = 1;

	}else{

		pre_GU = 1;
		pre_KI = 0;
	}

	if(left <= first && first <= right){
		if(first%2 == 0){

			return pre_GU;
		}else{

			return pre_KI;
		}
	}

	ll next_left,next_right;
	ll next_GU,next_KI;

	while(true){

		next_right = left-1;
		next_left = next_right/2+1;

		for(int i = 0; i < 3; i++){
			used[i] = false;
			used2[i] = false;
		}

		if(next_right%2 == 0){

			used[pre_KI] = true;
			used[pre_GU] = true;

			for(int i = 0; i < 3; i++){

				if(!used[i]){
					next_GU = i;
					break;
				}
			}

			used2[pre_GU] = true;
			used2[next_GU] = true;

			for(int i = 0; i < 3; i++){

				if(!used2[i]){
					next_KI = i;
					break;
				}
			}

		}else{

			used[pre_GU] = true;

			for(int i = 0; i < 3; i++){

				if(!used[i]){
					next_KI = i;
					break;
				}
			}

			used2[pre_GU] = true;
			used2[next_KI] = true;

			for(int i = 0; i < 3; i++){

				if(!used2[i]){
					next_GU = i;
					break;
				}
			}
		}

		if(next_left <= first && first <= next_right){

			if(first%2 == 0){

				return next_GU;
			}else{

				return next_KI;
			}
		}

		left = next_left;
		right = next_right;

		pre_GU = next_GU;
		pre_KI = next_KI;
	}
}


int main(){

	int K;
	scanf("%d",&K);

	ll XOR = 0;

	ll first,maxi;

	for(int loop = 0; loop < K; loop++){

		scanf("%lld %lld",&first,&maxi);
		XOR ^= grundy(first,maxi);
	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3168
final_rank: 3

code_snippet: //#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int mex(unordered_set<int>st) {
	REP(i, 3) {
		if (st.find(i) == st.end())return i;
	}
}

int calc_grundy(int N, int M) {
	if (N * 2 > M) {
		return (M - N) % 2;
	}
	else if (M&1) {
		if (N&1)return 0;
		int cnt = 0;
		while(M>=N){
			cnt++;
			M /= 2;
		}
		return 2 - (cnt&1);
	}
	else{
		int x, y, z;
		x = 0, y = 1, z = (M / 2) & 1 ? 0 : 1;
		bool even = 1;
		while (M/2 >= N) {
			if (M / 2 == 1 && N == 1) {
				if (M == 3)return mex({ y }); else return mex({ x });
			}
			//cout << "M:" << M;
			M /= 2;
			if (even) {
				//vector<int>v;
				//v.pb(z); v.pb(x);
				unordered_set<int>st;
				st.insert(z); st.insert(x);
				int new_x = mex(st);
				//vector<int>v2; v2.pb(new_x); v2.pb(x);
				unordered_set<int>st2;
				st2.insert(new_x); st2.insert(x);
				int new_y = mex(st2);
				int z_pos = M / 2 + 1;
				z = (M - z_pos) & 1 ? new_y : new_x;
				x=new_x; y = new_y;
			}
			else {
				unordered_set<int>st;
				st.insert(z); st.insert(y);
				int new_x = mex(st);
				unordered_set<int>st2;
				st2.insert(new_x); st2.insert(y);
				int new_y = mex(st2);
				int z_pos = M / 2 + 1;
				z = (M - z_pos) & 1 ? new_y : new_x;
				x = new_x; y = new_y;
			}
			//cout << "M:" << M << " x:" << x << " y:" << y << " z:" << z << endl;
			if (M % 2 == 0)even = true; else even = false;
		}
		//if (N == 2) { pe("M")print(M); };
		if ((M - N) & 1)return y; else return x;
	}
}
void show(int M) {
	FORR(i, M, 1) {
		pe(i)print(calc_grundy(i,M));
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	/*while (true) {
		int M; cin >> M;
		show(M);
	}*/
	//calc_grundy(3, 30);
	/*FORR(i, 20, 1) {
		pe(i)print(calc_grundy(i, 20));
	}*/
	//print(calc_grundy(2, 20));
	int grundy = 0;
	int K; cin >> K;
	int n, m;
	REP(i, K) {
		cin >> n >> m;
		/*FORR(j, m,1) {
			cout << j << ":" << calc_grundy(j, m) << endl;
		}*/
		grundy ^= calc_grundy(n, m);
	}
	if (grundy)print("mo3tthi")else print("tubuann");
}
accuracy: 1
time_ms: 270
memory_kb: 3212
final_rank: 14

code_snippet: #include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <typeinfo>
#include <cctype>

int grandy(long long int current, long long int max) {
	long long int lower = max / 2 + 1;
	assert(lower * 2 > max);
	assert((lower - 1) * 2 <= max);
	std::vector<int> pair(2);
	if (max % 2 == 0) {
		pair[0] = 0;
		pair[1] = 1;
	}
	else {
		pair[0] = 1;
		pair[1] = 0;
	}
	while (current < lower) {
		if (lower % 2 == 1) {
			int other = -1;
			if (std::find(pair.begin(), pair.end(), 0) == pair.end()) {
				other = 0;
			}
			else if (std::find(pair.begin(), pair.end(), 1) == pair.end()) {
				other = 1;
			}
			else {
				other = 2;
			}
			pair[0] = other;
			pair[1] = pair[1];
		}
		else {
			pair[1] = pair[0] == 0 ? 1 : 0;
			if (pair[0] == 2) {
				pair[0] = 1;
			}else {
				pair[0] = 2;
			}
		}
		lower = (lower + 1) / 2;
	}
	return current % 2 == 0 ? pair[0] : pair[1];
}

int main() {
	int n; std::cin >> n;
	int result = 0;
	for (auto i = 0; i < n; ++i) {
		long long int current, max; std::cin >> current >> max;
		result ^= grandy(current, max);
	}
	std::cout << (result != 0 ? "mo3tthi" : "tubuann") << std::endl;
}
accuracy: 1
time_ms: 90
memory_kb: 3120
final_rank: 11

code_snippet: #include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dat[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>k;
    rep(i,k){
        cin>>n>>m;
        ll hasi=m/2;
        ll ki,gu;
        if(m%2==0){
            gu=0;
            ki=1;
        }
        else{
            ki=0;
            gu=1;
        }
        while(1){
            if(hasi<n)break;
            int vi1[10]={};
            int vi2[10]={};
            if(hasi%2==1){
                vi1[gu]++;
                rep(j,3){
                    if(vi1[j]==0){
                        ki=j;
                        break;
                    }
                }
                vi2[ki]++;
                vi2[gu]++;
                rep(j,3){
                    if(vi2[j]==0){
                        gu=j;
                        break;
                    }
                }
            }
            else{
                vi1[gu]++;
                vi2[gu]++;
                vi1[ki]++;
                rep(j,3){
                    if(vi1[j]==0){
                        gu=j;
                        break;
                    }
                }
                vi2[gu]++;
                rep(j,3){
                    if(vi2[j]==0){
                        ki=j;
                        break;
                    }
                }
            }
            //cout<<hasi<<" "<<gu<<" "<<ki<<"\n";
            hasi/=2;
        }
        if(n%2==1)dat[i]=ki;
        else dat[i]=gu;
    }
    ans=dat[0];
    rrep(i,1,k){
        ans=(ans xor dat[i]);
    }
    if(ans==0)Cout("tubuann");
    else Cout("mo3tthi");
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4012
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
Int solve(){
  Int n,m;
  cin>>n>>m;
  if(n==m) return 0;

  Int a=0,b=1;
  while(m/2){
    assert(n<=m);
    Int x=m/2;
    // (x, m]
    if(x<n){
      return (~(m-n)&1)?a:b;
    }
    Int p=(x*2==m)?a:b;
    Int q=(~(m-(x+1))&1)?a:b;
    set<Int> ss;
    ss.emplace(p);
    ss.emplace(q);
    Int na=0;
    while(ss.count(na)) na++;

    if(x==1){
      assert(n==1);
      return na;
    }

    set<Int> st;
    st.emplace(p);
    st.emplace(na);
    Int nb=0;
    while(st.count(nb)) nb++;

    a=na;
    b=nb;
    m=x;
  }
  assert(0);
}

signed main(){
  Int t;
  cin>>t;
  Int ans=0;
  while(t--) ans^=solve();
  cout<<(ans?"mo3tthi":"tubuann")<<endl;
  return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 3188
final_rank: 13

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int grundy(ll x,ll MAX){

	ll left = MAX/2+1,right = MAX;

	int this_even,this_odd,pre_even,pre_odd;

	while(true){

		if(left == MAX/2+1){ //最初の区間

			if(right%2 == 0){

				this_even = 0; //右端は手詰まりなのでgrundyが0
				this_odd = 1;

			}else{ //right%2 == 1

				this_even = 1;
				this_odd = 0;
			}

		}else{

			bool check[3];
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			//まずは区間右端のgrundy数を求める
			int right_grundy;

			if(right%2 == 0){

				check[pre_odd] = true; //+1
				check[pre_even] = true;  //*2

			}else{ //right%2 == 1

				check[pre_even] = true;  //+1および*2
			}

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					right_grundy = i;
					break;
				}
			}

			int another_grundy;

			//右端の1つ左のgrundy数を求める
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			check[right_grundy] = true; //+1
			check[pre_even] = true; //*2

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					another_grundy = i;
					break;
				}
			}

			if(right%2 == 0){

				this_even = right_grundy;
				this_odd = another_grundy;

			}else{

				this_even = another_grundy;
				this_odd = right_grundy;
			}
		}

		if(x >= left && x <= right){

			if(x%2 == 0){

				return this_even;
			}else{

				return this_odd;
			}
		}

		right = left-1;
		left = right/2+1;

		pre_even = this_even;
		pre_odd = this_odd;
	}
}

int main(){

	int K;

	scanf("%d",&K);

	ll x,MAX;
	ll XOR = 0;

	for(int i = 0; i < K; i++){

		scanf("%lld %lld",&x,&MAX);

		XOR ^= grundy(x,MAX);
 	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3148
final_rank: 1

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int grundy(ll x,ll MAX){

	ll left = MAX/2+1,right = MAX;

	int this_even,this_odd,pre_even,pre_odd;

	while(true){

		if(left == MAX/2+1){ //最初の区間

			this_even = 0; //右端との位置の差が偶数ならgrundy==0
			this_odd = 1;

		}else{

			bool check[3];
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			//まずは区間右端のgrundy数を求める
			int right_grundy;

			if(right%2 == 0){

				check[pre_odd] = true; //+1
				check[pre_even] = true;  //*2

			}else{ //right%2 == 1

				check[pre_even] = true;  //+1および*2
			}

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					right_grundy = i;
					break;
				}
			}

			this_even = right_grundy;

			//右端との位置の差が奇数の場合
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			check[right_grundy] = true; //+1
			check[pre_even] = true; //*2

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					this_odd = i;
					break;
				}
			}
		}

		if(x >= left && x <= right){

			if((right-x)%2 == 0){

				return this_even;
			}else{

				return this_odd;
			}
		}

		right = left-1;
		left = right/2+1;

		pre_even = this_even;
		pre_odd = this_odd;
	}
}

int main(){

	int K;

	scanf("%d",&K);

	ll x,MAX;
	ll XOR = 0;

	for(int i = 0; i < K; i++){

		scanf("%lld %lld",&x,&MAX);

		XOR ^= grundy(x,MAX);
 	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}
accuracy: 0.12
time_ms: 10
memory_kb: 3152
final_rank: 18

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005


int grundy(ll x,ll MAX){

	ll left = MAX/2+1,right = MAX;

	int num_range = 0;

	while(true){

		if(x >= left && x <= right){

			if(num_range%2 == 0){ //1010101010...10

				return (right-left)%2;

			}else{ //212121212...12

				if((right-left)%2 == 0){

					return 2;

				}else{

					return 1;
				}
			}
		}

		right = left-1;
		left = right/2+1;

		num_range++;
	}
}

int main(){

	int K;

	scanf("%d",&K);

	ll x,MAX;
	ll XOR = 0;

	for(int i = 0; i < K; i++){

		scanf("%lld %lld",&x,&MAX);

		XOR ^= grundy(x,MAX);
	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}
accuracy: 0.16
time_ms: 10
memory_kb: 3132
final_rank: 16

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005


int grundy(int x,int MAX){

	int left = MAX/2+1,right = MAX;

	int num_range = 0;

	while(true){

		if(x >= left && x <= right){

			if(num_range%2 == 0){ //1010101010...10

				return (right-left)%2;

			}else{ //212121212...12

				if((right-left)%2 == 0){

					return 2;

				}else{

					return 1;
				}
			}
		}

		right = left-1;
		left = right/2+1;

		num_range++;
	}
}

int main(){

	int K;

	scanf("%d",&K);

	int x,MAX;
	int XOR = 0;

	for(int i = 0; i < K; i++){

		scanf("%d %d",&x,&MAX);

		XOR ^= grundy(x,MAX);
	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}
accuracy: 0.16
time_ms: 10
memory_kb: 3148
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int n,m;
int ans=0;

void solve(){
  int g[3]={0};
  int check=0,nex=1,nan=2;
  bool start=true;
  while(m/2 >= n){
    // bool odd=false;
    //if(m%2==1) odd=true;
    if(m%4==0){
      int f=nan;
      nan=check;
      check=f;
    }
    if(m%4==1){
      int f=nan;
      nan=nex;
      nex=check;
      check=f;
    }
    if(m%4==2){
      int a,b,c=check;
      a=min(nex,nan);
      b=max(nex,nan);
      check=a;
      nex=b;
      nan=c;
    }
    if(m%4==3){
      int a,b,c=nex;
      a=min(check,nan);
      b=max(check,nan);
      check=a;
      nex=b;
      nan=c;
    }
    m/=2;
    
  }
  if((m-n)%2) ans^=nex;
  else ans^=check;
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  rep(i,k){
    //cout<<1<<endl;
    cin>>n>>m;
    if(n==0 && m==0){cout<<endl;return 0;}
    solve();
  }
  if(ans) cout<<"mo3tthi"<<endl;
  else cout<<"tubuann"<<endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3216
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int grundy_(ll n, ll m, int a, int b) {
	if (n > m / 2) {
		if (n % 2 == m % 2)
			return a;
		else
			return b;
	}
	int g1 = grundy_((m / 2) * 2, m, a, b);
	int g2 = grundy_((m / 2) + 1, m, a, b);
	int next_a = 3;
	for (int i = 2; i >= 0; --i)
		if (i != g1 && i != g2)
			next_a = i;
	if (n == (m / 2)) return next_a;
	g1 = grundy_(((m / 2) - 1) * 2, m, a, b);
	int next_b = 3;
	for (int i = 2; i >= 0; --i)
		if (i != g1 && i != next_a)
			next_b = i;
	if (n == (m / 2) - 1) return next_b;
	return grundy_(n, (m / 2), next_a, next_b);
}

int grundy(ll n, ll m) {
	if (n == 2 && m >= 4) {
		int g1 = grundy(3, m);
		int g2 = grundy(4, m);
		for (int i = 0; i < 3; ++i)
			if (i != g1 && i != g2)
				return i;
	}
	if (n == 1 && m >= 2) {
		int g = grundy(2, m);
		for (int i = 0; i < 3; ++i)
			if (i != g)
				return i;
	}
	return grundy_(n, m, 0, 1);
}

signed main() {
	int k; cin >> k;

	int tmp = 0;
	while (k--) {
		ll n, m;
		cin >> n >> m;
		tmp ^= grundy(n, m);
	}

	if (tmp)
		cout << "mo3tthi" << endl;
	else
		cout << "tubuann" << endl;

	return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3116
final_rank: 10

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int grundy_(ll n, ll m, int a, int b) {
	if (n > m / 2) {
		if (n % 2 == m % 2)
			return a;
		else
			return b;
	}
	int g1 = grundy_((m / 2) * 2, m, a, b);
	int g2 = grundy_((m / 2) + 1, m, a, b);
	int next_a = 3;
	for (int i = 3; i >= 0; --i)
		if (i != g1 && i != g2)
			next_a = i;
	if (n == (m / 2)) return next_a;
	g1 = grundy_(((m / 2) - 1) * 2, m, a, b);
	int next_b = 3;
	for (int i = 3; i >= 0; --i)
		if (i != g1 && i != next_a)
			next_b = i;
	if (n == (m / 2) - 1) return next_b;
	return grundy_(n, (m / 2), next_a, next_b);
}

int grundy(ll n, ll m) {
	if (n == 2 && m >= 4) {
		int g1 = grundy(3, m);
		int g2 = grundy(4, m);
		for (int i = 3; i >= 0; --i)
			if (i != g1 && i != g2)
				return i;
	}
	if (n == 1 && m >= 2) {
		int g = grundy(2, m);
		for (int i = 3; i >= 0; --i)
			if (i != g)
				return i;
	}
	return grundy_(n, m, 0, 1);
}

signed main() {
	int k; cin >> k;

	int tmp = 0;
	while (k--) {
		ll n, m;
		cin >> n >> m;
		tmp ^= grundy(n, m);
	}

	if (tmp)
		cout << "mo3tthi" << endl;
	else
		cout << "tubuann" << endl;

	return 0;
}
accuracy: 0.06
time_ms: 20
memory_kb: 3096
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

int mex(int a, int b){
    for(int i=0; ; i++) if(a != i && b != i) return i;
}

int solve(){
    int64_t N, M;
    cin >> N >> M;
    vector<int> g = {0, 1};
    while(true){
        if(N == M) return g[0];
        if(M%2){
            M--;
            swap(g[0], g[1]);
        }
        int64_t m = M/2;
        if(m < N) return g[(M-N)%2];
        int v0 = mex(g[0], g[(M-m+1)%2]);
        int v1 = mex(v0, (m==2 ? v0 : g[0]));
        M = m;
        g = {v0, v1};
    }
}

int main() {
    int K;
    cin >> K;
    int G = 0;
    while(K--) G ^= solve();
    cout << (G ? "mo3tthi" : "tubuann") << endl;
    return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3124
final_rank: 12

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int grundy(ll n, ll m){
    if(n==1){
        return grundy(2,m) == 0;
    }
    ll l = m/2, r = m, cnt = 0, ev = m%2, od = (m+1)%2;
    while(l >= n){
        r = l;
        l >>= 1;
        cnt++;
        if(r%2){
            if(ev == 0){
                od = 1;
                ev = 2;
            }
            else if(ev == 1){
                od = 0;
                ev = 2;
            }
            else{
                od = 0;
                ev = 1;
            }
        }
        else{
            bool used[3]{};
            int pev = ev;
            used[pev] = true;
            used[od] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    ev = i;
                    break;
                }
            }
            fill(used, used+3, false);
            used[pev] = true;
            used[ev] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    od = i;
                    break;
                }
            }
        }
    }
    return (n%2 ? od : ev);
}

int main(){
    ll k, allxor = 0;
    cin >> k;

    for(int i=0;i<k;i++){
        ll n, m;
        cin >> n >> m;
        allxor ^= grundy(n, m);
    }
    if(allxor == 0){
        cout << "tubuann" << endl;
    }
    else{
        cout << "mo3tthi" << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3116
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int solve(ll n, ll m){
    if(n==1){
        return solve(2,m) == 0;
    }
    ll l = m/2, r = m, cnt = 0, ev = m%2, od = (m+1)%2;
    while(l >= n){
        r = l;
        l >>= 1;
        cnt++;
        if(r%2){
            if(ev == 0){
                od = 1;
                ev = 2;
            }
            else if(ev == 1){
                od = 0;
                ev = 2;
            }
            else{
                od = 0;
                ev = 1;
            }
        }
        else{
            bool used[3]{};
            int pev = ev;
            used[pev] = true;
            used[od] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    ev = i;
                    break;
                }
            }
            fill(used, used+3, false);
            used[pev] = true;
            used[ev] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    od = i;
                    break;
                }
            }
        }
    }
    return (n%2 ? od : ev);
}

int main(){
    ll k, allxor = 0;
    cin >> k;

    for(int i=0;i<k;i++){
        ll n, m;
        cin >> n >> m;
        allxor ^= solve(n, m);
    }
    if(allxor == 0){
        cout << "tubuann" << endl;
    }
    else{
        cout << "mo3tthi" << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3120
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int solve(ll n, ll m){
    if(n==1){
        return solve(2,m) == 0;
    }
    ll l = m/2, r = m, cnt = 0, ev = m%2, od = (m+1)%2;
    while(l >= n){
        r = l;
        l >>= 1;
        cnt++;
        if(r%2){
            if(ev == 0){
                od = 1;
                ev = 2;
            }
            if(ev == 1){
                od = 0;
                ev = 2;
            }
            else{
                od = 0;
                ev = 1;
            }
        }
        else{
            bool used[3]{};
            int pev = ev;
            used[pev] = true;
            used[od] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    ev = i;
                    break;
                }
            }
            fill(used, used+3, false);
            used[pev] = true;
            used[ev] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    od = i;
                    break;
                }
            }
        }
    }
    return (n%2 ? od : ev);
}

int main(){
    ll k, allxor = 0;
    cin >> k;

    for(int i=0;i<k;i++){
        ll n, m;
        cin >> n >> m;
        allxor ^= solve(n, m);
    }
    if(allxor == 0){
        cout << "tubuann" << endl;
    }
    else{
        cout << "mo3tthi" << endl;
    }
    return 0;
}
accuracy: 0.08
time_ms: 20
memory_kb: 3100
final_rank: 19