Two cats and a mouse are at various positions on a line.  You will be given their starting positions.  Your task is to determine which cat will reach the mouse first, assuming the mouse does not move and the cats travel at equal speed.  If the cats arrive at the same time, the mouse will be allowed to move and it will escape while they fight.

You are given $\textit{q}$ queries in the form of $\boldsymbol{x}$, $y$, and $z$ representing the respective positions for cats $\mbox{A}$ and $\mbox{B}$, and for mouse $\mbox{C}$. Complete the function $catAndMouse$ to return the appropriate answer to each query, which will be printed on a new line.

If cat $\mbox{A}$ catches the mouse first, print Cat A.
If cat $\mbox{B}$ catches the mouse first, print Cat B.
If both cats reach the mouse at the same time, print Mouse C as the two cats fight and mouse escapes.  

Example  

$x=2$ 

$y=5$ 

$z=4$  

The cats are at positions $2$ (Cat A) and $5$ (Cat B), and the mouse is at position $4$.  Cat B, at position $5$ will arrive first since it is only $1$ unit away while the other is $2$ units away.  Return 'Cat B'.  

Function Description  

Complete the catAndMouse function in the editor below.  

catAndMouse has the following parameter(s):  

int x: Cat $\mbox{A}$'s position  
int y: Cat $\mbox{B}$'s position  
int z: Mouse $\mbox{C}$'s position  

Returns  

string:  Either 'Cat A', 'Cat B', or 'Mouse C'

Input Format

The first line contains a single integer, $\textit{q}$, denoting the number of queries. 

Each of the $\textit{q}$ subsequent lines contains three space-separated integers describing the respective values of $\boldsymbol{x}$ (cat $\mbox{A}$'s location), $y$ (cat $\mbox{B}$'s location), and $z$ (mouse $\mbox{C}$'s location).

Constraints

$1\leq q\leq100$  
$1\le x,y,z\le100$  

Sample Input 0
2
1 2 3
1 3 2

Sample Output 0
Cat B
Mouse C

Explanation 0

Query 0: The positions of the cats and mouse are shown below:

Cat $\mbox{B}$ will catch the mouse first, so we print Cat B on a new line.

Query 1: In this query, cats $\mbox{A}$ and $\mbox{B}$ reach mouse $\mbox{C}$ at the exact same time:

Because the mouse escapes, we print Mouse C on a new line.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	d1 = abs(x - z)
	d2 = abs(y - z)
	if d1 == d2:
		print('Mouse C')
	elif d1 < d2:
		print('Cat A')
	elif d1 > d2:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dx = abs(x - z)
	dy = abs(y - z)
	if dx < dy:
		print('Cat A')
	elif dx > dy:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) == abs(z - y):
		print('Mouse C')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) == abs(y - z):
		print('Mouse C')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	distx = abs(z - x)
	disty = abs(z - y)
	if disty < distx:
		print('Cat B')
	elif distx < disty:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	catA = abs(x - z)
	catB = abs(y - z)
	if catA == catB:
		print('Mouse C')
	elif catA > catB:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	cat_one = abs(z - x)
	cat_two = abs(z - y)
	if cat_one < cat_two:
		print('Cat A')
	elif cat_two < cat_one:
		print('Cat B')
	else:
		print('Mouse C')


q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	lista = [x, z]
	listb = [y, z]
	xa = max(lista) - min(lista)
	ya = max(listb) - min(listb)
	if xa == ya:
		print('Mouse C')
	elif xa > ya:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	distA = abs(x - z)
	distB = abs(y - z)
	if distA == distB:
		print('Mouse C')
	elif distA > distB:
		print('Cat B')
	else:
		print('Cat A')


q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Mouse C')


for _ in range(int(input())):
	(catA, catB, mouseC) = map(int, input().split())
	print('Cat A' if abs(catA - mouseC) < abs(catB - mouseC) else 'Cat B' if abs(catA - mouseC) > abs(catB - mouseC) else 'Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	adist = abs(x - z)
	bdist = abs(y - z)
	if adist < bdist:
		print('Cat A')
	elif bdist < adist:
		print('Cat B')
	else:
		print('Mouse C')


import sys
for t in range(0, int(input().strip())):
	(x, y, z) = map(int, input().strip().split(' '))
	(dx, dy) = (abs(x - z), abs(y - z))
	if dx == dy:
		print('Mouse C')
	elif dx < dy:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	if abs(x - z) < abs(y - z):
		print('Cat A')
	if abs(x - z) == abs(y - z):
		print('Mouse C')


import sys
n = int(input())
for i in range(n):
	q = list(map(int, input().split()))
	cat1 = q[0]
	cat2 = q[1]
	mouse = q[2]
	d1 = abs(cat1 - mouse)
	d2 = abs(cat2 - mouse)
	if d1 == d2:
		print('Mouse C')
	elif d1 > d2:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	a_d = abs(z - x)
	b_d = abs(z - y)
	if a_d < b_d:
		print('Cat A')
	elif b_d < a_d:
		print('Cat B')
	else:
		print('Mouse C')


import sys
import math
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if math.fabs(x - z) == math.fabs(y - z):
		print('Mouse C')
	elif math.fabs(x - z) < math.fabs(y - z):
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(y - z) > abs(x - z):
		print('Cat A')
	else:
		print('Mouse C')


q = int(input())
queries = []
for triple in range(q):
	queries.append([int(i) for i in input().split()])
for (a, b, c) in queries:
	if abs(a - c) < abs(b - c):
		print('Cat A')
	elif abs(a - c) > abs(b - c):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	a = abs(z - x)
	b = abs(z - y)
	if a == b:
		print('Mouse C')
	if a < b:
		print('Cat A')
	if b < a:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	catADist = abs(x - z)
	catBDist = abs(y - z)
	if catADist > catBDist:
		print('Cat B')
	elif catBDist > catADist:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) < abs(z - y):
		print('Cat A')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	else:
		print('Mouse C')


inf = float('inf')
read_ints = lambda : list(map(int, input().split()))

def solve(x, y, z):
	if abs(z - x) == abs(z - y):
		print('Mouse C')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Cat B')
T = int(input())
for _ in range(T):
	(x, y, z) = read_ints()
	solve(x, y, z)


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) == abs(y - z):
		print('Mouse C')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - y) < abs(z - x):
		print('Cat B')
	elif abs(z - y) > abs(z - x):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	if abs(x - z) < abs(z - y):
		print('Cat A')
	if abs(x - z) == abs(y - z):
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	diff_xz = abs(z - x)
	diff_yz = abs(z - y)
	if diff_xz > diff_yz:
		print('Cat B')
	elif diff_yz > diff_xz:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = [int(temp) for temp in input().strip().split(' ')]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	xz = abs(x - z)
	yz = abs(y - z)
	if xz < yz:
		print('Cat A')
	elif yz < xz:
		print('Cat B')
	elif yz == xz:
		print('Mouse C')


for i in range(int(input())):
	a = list(map(int, input().split()))
	A = a[0]
	B = a[1]
	C = a[2]
	X1 = abs(C - A)
	X2 = abs(C - B)
	if X1 == X2:
		print('Mouse C')
	elif X1 < X2:
		print('Cat A')
	else:
		print('Cat B')


T = int(input())
for t in range(T):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	catx = 'Cat A'
	caty = 'Cat B'
	if y < x:
		(x, y) = (y, x)
		catx = 'Cat B'
		caty = 'Cat A'
	if x == y:
		print('Mouse C')
		continue
	if z > y:
		print(caty)
	elif z < x:
		print(catx)
	else:
		diffA = z - x
		diffB = y - z
		if diffA == diffB:
			print('Mouse C')
		elif diffA > diffB:
			print(caty)
		else:
			print(catx)


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - y) < abs(z - x):
		print('Cat B')
		continue
	if abs(z - y) > abs(z - x):
		print('Cat A')
		continue
	if abs(x - z) == abs(y - z):
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = map(int, input().split())
	if abs(z - x) > abs(z - y):
		print('Cat B')
	if abs(z - x) < abs(z - y):
		print('Cat A')
	if abs(z - x) == abs(z - y):
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - y) > abs(z - x):
		print('Cat A')
	elif abs(z - y) < abs(z - x):
		print('Cat B')
	else:
		print('Mouse C')


for i in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	if abs(a - c) != abs(b - c):
		if abs(a - c) > abs(b - c):
			win = 'Cat B'
		else:
			win = 'Cat A'
	else:
		win = 'Mouse C'
	print(win)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x == y:
		print('Mouse C')
	elif x < y:
		if y <= z:
			print('Cat B')
		elif x >= z:
			print('Cat A')
		elif z - x < y - z:
			print('Cat A')
		elif z - x > y - z:
			print('Cat B')
		else:
			print('Mouse C')
	elif x <= z:
		print('Cat A')
	elif y >= z:
		print('Cat B')
	elif x - z < z - y:
		print('Cat A')
	elif x - z > z - y:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	a = abs(x - z)
	b = abs(y - z)
	if a > b:
		print('Cat B')
	elif b > a:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


Q = int(input().strip())
for _ in range(Q):
	(A, B, C) = map(int, input().strip().split())
	aDist = abs(A - C)
	bDist = abs(B - C)
	if aDist == bDist:
		print('Mouse C')
	elif aDist < bDist:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dx = abs(x - z)
	dy = abs(y - z)
	if dx == dy:
		print('Mouse C')
	elif dx > dy:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = [int(s) for s in input().strip().split(' ')]
	if abs(y - z) > abs(x - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) == abs(y - z):
		print('Mouse C')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dx = abs(x - z)
	dy = abs(y - z)
	if dx < dy:
		print('Cat A')
	elif dy < dx:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) is abs(z - y):
		print('Mouse C')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dist_a = abs(z - x)
	dist_b = abs(z - y)
	if dist_a == dist_b:
		print('Mouse C')
	elif dist_a < dist_b:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) == abs(y - z):
		print('Mouse C')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	disA = abs(x - z)
	disB = abs(y - z)
	if disA > disB:
		print('Cat B')
	elif disA < disB:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	cata = abs(x - z)
	catb = abs(y - z)
	if cata == catb:
		print('Mouse C')
	elif cata > catb:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	x_distance = abs(x - z)
	y_distance = abs(y - z)
	if y_distance > x_distance:
		print('Cat A')
	elif x_distance > y_distance:
		print('Cat B')
	elif x_distance == y_distance:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	x_diff = abs(z - x)
	y_diff = abs(z - y)
	if x_diff == y_diff:
		print('Mouse C')
	elif x_diff > y_diff:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) < abs(z - y):
		print('Cat A')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if x <= z <= y or y <= z <= x:
		if abs(z - x) == abs(y - z):
			print('Mouse C')
		elif abs(z - x) < abs(y - z):
			print('Cat A')
		else:
			print('Cat B')
	elif x == y:
		print('Mouse C')
	elif x < y <= z or z <= y < x:
		print('Cat B')
	elif y < x <= z or z <= x < y:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(a, b, c) = map(int, input().split(' '))
	if abs(a - c) > abs(b - c):
		print('Cat B')
	elif abs(a - c) < abs(b - c):
		print('Cat A')
	else:
		print('Mouse C')


import sys
import math
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) < abs(z - y):
		print('Cat A')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	elif abs(z - x) == abs(z - y):
		print('Mouse C')


import sys
from math import *
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if fabs(x - z) > fabs(y - z):
		print('Cat B')
	elif fabs(y - z) > fabs(x - z):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	A = abs(z - x)
	B = abs(z - y)
	if A == B:
		print('Mouse C')
	elif A < B:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	d1 = abs(x - z)
	d2 = abs(y - z)
	if d1 < d2:
		print('Cat A')
	elif d2 < d1:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
if q == 0 or q > 100:
	q = 1
	print('Setting q to 1')
lord = []
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if x < z:
		dX = z - x
	else:
		dX = x - z
	if y < z:
		dY = z - y
	else:
		dY = y - z
	if dX < dY:
		lord.append('Cat A')
	elif dY < dX:
		lord.append('Cat B')
	else:
		lord.append('Mouse C')
for i in lord:
	print(i)


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	distA = x - z
	if distA < 0:
		distA = -distA
	distB = y - z
	if distB < 0:
		distB = -distB
	if distA < distB:
		print('Cat A')
	elif distB < distA:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(a, b, c) = [int(x), int(y), int(z)]
	if abs(a - c) > abs(b - c):
		print('Cat B')
	elif abs(a - c) == abs(b - c):
		print('Mouse C')
	elif abs(b - c) > abs(a - c):
		print('Cat A')


x = int(input())
l = []
for x in range(x):
	l = list(map(int, input().split()))
	cat1 = l[0]
	cat2 = l[1]
	rat = l[2]
	s = abs(rat - cat1)
	s1 = abs(rat - cat2)
	if s == s1:
		print('Mouse C')
	elif s > s1:
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dx = abs(x - z)
	dy = abs(y - z)
	if dx == dy:
		print('Mouse C')
	elif dx > dy:
		print('Cat B')
	else:
		print('Cat A')


import sys
a = []
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		a.append('Cat A')
	elif abs(x - z) > abs(y - z):
		a.append('Cat B')
	else:
		a.append('Mouse C')
for i in a:
	print(i)


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) > abs(z - y):
		print('Cat B')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = map(int, input().strip().split(' '))
	x1 = x - z
	y1 = y - z
	if x1 < 0:
		x1 = -x1
	if y1 < 0:
		y1 = -y1
	if y1 > x1:
		print('Cat A')
	elif x1 > y1:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	elif abs(x - z) < abs(y - z):
		print('Cat A')
	else:
		print('Mouse C')


q = int(input().strip())
for a in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if ((x + y) / 2).is_integer() and int((x + y) / 2) == z or x == y:
		print('Mouse C')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Cat B')


a = int(input())
c = []
for i in range(0, a):
	b = input().strip().split()
	c = [int(i) for i in b]
	if abs(c[2] - c[0]) > abs(c[2] - c[1]):
		print('Cat B')
	if abs(c[2] - c[0]) < abs(c[2] - c[1]):
		print('Cat A')
	if abs(c[2] - c[0]) == abs(c[2] - c[1]):
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	distanceFromA = abs(x - z)
	distanceFromB = abs(y - z)
	if distanceFromA > distanceFromB:
		print('Cat B')
	elif distanceFromA < distanceFromB:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(abs(z) - abs(x)) > abs(abs(z) - abs(y)):
		print('Cat B')
	elif abs(abs(z) - abs(x)) < abs(abs(z) - abs(y)):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	m = abs(x - z)
	n = abs(y - z)
	if m == n:
		print('Mouse C')
	elif m < n:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	comp = abs(x - z) - abs(y - z)
	if comp < 0:
		print('Cat A')
	elif comp > 0:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) == abs(z - y):
		print('Mouse C')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	else:
		print('Cat A')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	a = abs(z - y)
	b = abs(z - x)
	if a > b:
		print('Cat A')
	elif a < b:
		print('Cat B')
	elif a == b:
		print('Mouse C')


t = int(input())
i = 0
while i < t:
	arr = list(map(int, input().split()))
	if abs(arr[2] - arr[0]) < abs(arr[2] - arr[1]):
		print('Cat A')
	if abs(arr[2] - arr[0]) > abs(arr[2] - arr[1]):
		print('Cat B')
	if abs(arr[2] - arr[0]) == abs(arr[2] - arr[1]):
		print('Mouse C')
	i = i + 1


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) < abs(y - z):
		print('Cat A')
	elif abs(x - z) > abs(y - z):
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dx = abs(x - z)
	dy = abs(y - z)
	if dx < dy:
		print('Cat A')
	elif dx > dy:
		print('Cat B')
	else:
		print('Mouse C')


q = int(input().strip())
for i in range(q):
	(x, y, z) = map(int, input().strip().split(' '))
	xmoves = abs(z - x)
	ymoves = abs(z - y)
	poss = ['Cat A', 'Mouse C', 'Cat B']
	ans = (xmoves > ymoves) - (ymoves > xmoves) + 1
	print(poss[ans])


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	dis_a = abs(x - z)
	dis_b = abs(y - z)
	if dis_a < dis_b:
		print('Cat A')
	elif dis_b < dis_a:
		print('Cat B')
	else:
		print('Mouse C')


q = int(input().strip())
for i in range(q):
	(x, y, z) = map(int, input().strip().split(' '))
	xmoves = abs(z - x)
	ymoves = abs(z - y)
	poss = ['Cat A', 'Mouse C', 'Cat B']
	ans = (xmoves > ymoves) - (ymoves > xmoves) + 1
	print(poss[ans])


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	catADist = abs(x - z)
	catBDist = abs(y - z)
	if catADist < catBDist:
		print('Cat A')
	elif catADist > catBDist:
		print('Cat B')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) > abs(z - y):
		print('Cat B')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) == abs(z - y):
		print('Mouse C')
	elif abs(z - x) > abs(z - y):
		print('Cat B')
	else:
		print('Cat A')


import sys
from math import fabs
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if fabs(x - z) == fabs(y - z):
		print('Mouse C')
	elif fabs(x - z) < fabs(y - z):
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(z - x) < abs(z - y):
		print('Cat A')
	elif abs(z - x) == abs(z - y):
		print('Mouse C')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	if abs(x - z) > abs(y - z):
		print('Cat B')
	if abs(x - z) < abs(y - z):
		print('Cat A')
	if abs(x - z) == abs(y - z):
		print('Mouse C')


t = int(input())
for _ in range(t):
	(x, y, z) = map(int, input().split())
	(xz, yz) = (abs(x - z), abs(y - z))
	if xz > yz:
		print('Cat B')
	elif xz < yz:
		print('Cat A')
	else:
		print('Mouse C')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = input().strip().split(' ')
	(x, y, z) = [int(x), int(y), int(z)]
	first_dist = abs(x - z)
	second_dist = abs(y - z)
	if first_dist == second_dist:
		print('Mouse C')
	elif first_dist < second_dist:
		print('Cat A')
	else:
		print('Cat B')


import sys
q = int(input().strip())
for a0 in range(q):
	(x, y, z) = map(int, input().strip().split(' '))
	if abs(z - x) > abs(z - y):
		print('Cat B')
	elif abs(z - x) < abs(z - y):
		print('Cat A')
	else:
		print('Mouse C')