Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Ari and Rich are playing a pretty confusing game. Here are the rules of the game:
The game is played with two piles of matches. Initially, the first pile contains $N$ matches and the second one contains $M$ matches.
The players alternate turns; Ari plays first.
On each turn, the current player must choose one pile and remove a positive number of matches (not exceeding the current number of matches on that pile) from it.
It is only allowed to remove $X$ matches from a pile if the number of matches in the other pile divides $X$.
The player that takes the last match from any pile wins.

It can be proved that as long as both piles are non-empty, there is always at least one valid move, so the game must end by emptying some pile. Both Ari and Rich play optimally. Determine the winner of the game.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains two space-separated integers $N$ and $M$.

------  Output ------
For each test case, print a single line containing the string "Ari" (without quotes) if Ari wins or "Rich" (without quotes) if Rich wins.

------  Constraints  ------
$1 ≤ T ≤ 10^{5}$
$1 ≤ N, M ≤ 10^{18}$

------  Subtasks ------
Subtask #1 (30 points): $1 ≤ N, M ≤ 1,000$

Subtask #2 (70 points): original constraints

----- Sample Input 1 ------ 
5

1 1

2 2

1 3

155 47

6 4
----- Sample Output 1 ------ 
Ari

Ari

Ari

Ari

Rich
----- explanation 1 ------ 
One possible sequence of moves for the fourth test case is:
$(155, 47) \rightarrow (61, 47) \rightarrow (14, 47) \rightarrow (14, 19) \rightarrow (14, 5) \rightarrow (4, 5) \rightarrow (4, 1) \rightarrow (0, 1)$

Difficulty: MEDIUM_HARD

Solutions:
t = int(input())
for i in range(t):
	n = list(map(int, input().split()))
	f = True
	n.sort()
	while n[1] % n[0] != 0 and n[1] // n[0] < 2:
		n[1] = n[1] % n[0]
		f = not f
		n.sort()
	print('Rich' if f == False else 'Ari')


for t in range(int(input())):
	n = [int(x) for x in input().split()]
	flag = True
	n.sort()
	while n[1] % n[0] != 0 and n[1] // n[0] < 2:
		n[1] = n[1] % n[0]
		flag = not flag
		n.sort()
	if not flag:
		print('Rich')
	else:
		print('Ari')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	n1 = max(n, m)
	m1 = min(n, m)
	if n1 % m1 == 0:
		print('Ari')
	else:
		c = 1
		while n1 % m1 != 0 and n1 // m1 <= 1:
			c += 1
			n1 -= n1 // m1 * m1
			temp = n1
			n1 = m1
			m1 = temp
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	ari_turn = True
	bigger_pile = n if n >= m else m
	smaller_pile = m if bigger_pile == n else n
	while bigger_pile % smaller_pile != 0 and bigger_pile // smaller_pile <= 1:
		bigger_pile = bigger_pile % smaller_pile
		ari_turn = not ari_turn
		(bigger_pile, smaller_pile) = (smaller_pile, bigger_pile)
	if not ari_turn:
		print('Rich')
	else:
		print('Ari')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l = 1
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		a = max(m, n)
		b = min(m, n)
		while a % b != 0 and a // b <= 1:
			l += 1
			a -= a // b * b
			t = b
			b = a
			a = t
		if l % 2 == 0:
			print('Rich')
		else:
			print('Ari')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 1
	if a % b == 0 or b % a == 0:
		print('Ari')
	else:
		p = max(a, b)
		q = min(a, b)
		while p % q != 0 and p // q <= 1:
			c += 1
			p -= p // q * q
			t = q
			q = p
			p = t
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	if n % m == 0:
		print('Ari')
	elif m % n == 0:
		print('Ari')
	else:
		large = max(m, n)
		small = min(m, n)
		count = 0
		while True:
			remind = large % small
			quotient = large // small
			count += 1
			if quotient > 1:
				break
			else:
				large = small
				small = remind
				if small > large:
					(small, large) = (large, small)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def winner(m, n, x):
	if m % n == 0 or n % m == 0:
		return x
	if m > n:
		if m // n > 1:
			return x
		return winner(m % n, n, 1 - x)
	else:
		if n // m > 1:
			return x
		return winner(m, n % m, 1 - x)
t = int(input())
for jack in range(t):
	(n, m) = map(int, input().split())
	if winner(m, n, 0):
		print('Rich')
	else:
		print('Ari')


from sys import stdin
T = int(stdin.readline())
while T:
	(N, M) = list(map(int, stdin.readline().split()))
	R = False
	if N % M == 0 or M % N == 0:
		print('Ari')
	else:
		mx = max(N, M)
		mn = min(N, M)
		while True:
			r = mx % mn
			R = not R
			if mx // mn > 1:
				break
			else:
				mx = mn
				mn = r
				if mx < mn:
					(mx, mn) = (mn, mx)
		if R:
			print('Ari')
		else:
			print('Rich')
	T -= 1


for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	if m % n == 0 or n % m == 0:
		print('Ari')
	else:
		small = min(n, m)
		big = max(n, m)
		count = 0
		while True:
			rem = big % small
			quo = big // small
			count += 1
			if quo > 1:
				break
			else:
				big = small
				small = rem
				if big < small:
					(big, small) = (small, big)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def check(Max, Min):
	if Max % Min == 0 or Max // Min > 1:
		return List[0]
	else:
		List[0] += 1
		Max = Max - Min * (Max // Min)
		return check(max(Max, Min), min(Max, Min))
for _ in range(int(input())):
	(N, M) = [int(x) for x in input().split()]
	List = [0]
	Max = max(N, M)
	Min = min(N, M)
	count = check(Max, Min)
	if count % 2 == 0:
		print('Ari')
	else:
		print('Rich')


k = int(input())
for i in range(k):
	(a, b) = map(int, input().split())
	x = 0
	if b > a:
		(a, b) = (b, a)
	while a % b != 0:
		if b > a:
			(a, b) = (b, a)
		if a // b > 1:
			break
		else:
			a = a % b
		x = x + 1
	if x % 2 == 0:
		print('Ari')
	else:
		print('Rich')


for _ in range(int(input())):
	nm = sorted(map(int, input().split()))
	c = 0
	while nm[0] != 0:
		if nm[1] // nm[0] > 1:
			c += 1
			break
		nm[1] = nm[1] % nm[0]
		nm.sort()
		c += 1
	if c % 2 == 0:
		print('Rich')
	else:
		print('Ari')


def gcd(a, b):
	if b == 0:
		return 0
	return 1 if a // b > 1 else gcd(b, a % b) + 1
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	if m > n:
		l = m
		m = n
		n = l
	k = gcd(n, m)
	if k & 1:
		print('Ari')
	else:
		print('Rich')


t = int(input())
while t:
	(n, m) = list(map(int, input().split()))
	if m % n == 0:
		print('Ari')
	elif n % m == 0:
		print('Ari')
	else:
		greater = max(m, n)
		smaller = min(m, n)
		count = 0
		while True:
			remainder = greater % smaller
			quotient = greater // smaller
			count += 1
			if quotient > 1:
				break
			else:
				greater = smaller
				smaller = remainder
				if greater < smaller:
					(greater, smaller) = (smaller, greater)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')
	t -= 1


def gcd(x, y):
	counts = []
	while y and x:
		counts.append(int(x / y))
		(x, y) = (y, x % y)
	return counts
t = int(input())
while t:
	(n, m) = [int(ele) for ele in input().split()]
	counts = gcd(max(m, n), min(m, n))
	ans = 'Ari'
	for i in range(len(counts) - 2, -1, -1):
		if ans == 'Ari':
			if counts[i] > 1:
				ans = 'Ari'
			else:
				ans = 'Rich'
		else:
			ans = 'Ari'
	print(ans)
	t -= 1


T = int(input())
while T > 0:
	(n, m) = map(int, input().split())
	if n % m == 0:
		print('Ari')
	elif m % n == 0:
		print('Ari')
	else:
		larger = max(n, m)
		smaller = min(n, m)
		count = 0
		while True:
			if larger == 0 or smaller == 0:
				break
			r = larger % smaller
			q = larger // smaller
			count += 1
			if q > 1:
				break
			larger = smaller
			smaller = r
			if larger < smaller:
				(larger, smaller) = (smaller, larger)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')
	T -= 1


t = int(input())
while t > 0:
	t = t - 1
	(a, b) = map(int, input().split())
	count = 0
	if b > a:
		(a, b) = (b, a)
	while a % b != 0:
		if b > a:
			(a, b) = (b, a)
		if a // b > 1:
			break
		else:
			a = a % b
		count = count + 1
	if count % 2 == 0:
		print('Ari')
	else:
		print('Rich')


for _ in range(int(input())):
	(n, m) = map(int, input().strip().split())
	count = 0
	if n == m:
		print('Ari')
	else:
		while max(n, m) / min(n, m) < 2:
			if n > m:
				p = int(n / m)
				n = n - p * m
			else:
				p = int(m / n)
				m = m - p * n
			count += 1
		if count % 2 == 0:
			print('Ari')
		else:
			print('Rich')


def show(t):
	for lo in range(t):
		(a, b) = map(int, input().strip().split(' '))
		count = 0
		if a == b:
			print('Ari')
		else:
			while max(a, b) / min(a, b) < 2:
				if a > b:
					p = int(a / b)
					a = a - p * b
				else:
					p = int(b / a)
					b = b - p * a
				count += 1
			if count % 2 == 0:
				print('Ari')
			else:
				print('Rich')
show(int(input()))


t = int(input())
while t > 0:
	t -= 1
	c = 0
	(n, m) = map(int, input().split())
	while n > 0 and m > 0:
		c += 1
		if n > m:
			if n < 2 * m:
				r = n % m
				if r == 0:
					n = 0
				else:
					n = r
			else:
				if c % 2 == 0:
					print('Rich')
				else:
					print('Ari')
				n = 0
		elif n == m:
			if c % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			n = 0
		elif m < 2 * n:
			r = m % n
			if r == 0:
				n = 0
			else:
				m = r
		else:
			if c % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			n = 0


def solve(n, m):
	if m == 1 or n >= 2 * m or n % m == 0:
		return 'Ari'
	n -= n // m * m
	(n, m) = (m, n)
	other = solve(n, m)
	if other == 'Ari':
		return 'Rich'
	return 'Ari'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	print(solve(n, m))


t = int(input())
for i in range(t):
	lol = input().split()
	n = int(lol[0])
	m = int(lol[1])
	x = 0
	y = 0
	while n > 0 and m > 0 and (y == 0):
		if n > m:
			if int(n / m) > 1:
				y = 1
				x += 1
			else:
				n = n % m
				x += 1
		elif int(m / n) > 1:
			y = 1
			x += 1
		else:
			m = m % n
			x += 1
	if x % 2 != 0:
		print('Ari')
	else:
		print('Rich')


t = int(input())
for i in range(t):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		large = max(n, m)
		small = min(n, m)
		count = 0
		while True:
			reminder = large % small
			quotient = large // small
			count += 1
			if quotient > 1:
				break
			else:
				large = small
				small = reminder
				if large < small:
					(large, small) = (small, large)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if m % n == 0 or n % m == 0:
		print('Ari')
	else:
		if n < m:
			(n, m) = (m, n)
		c = 0
		while 1:
			r = n % m
			q = n // m
			c += 1
			if q > 1:
				break
			else:
				n = m
				m = r
				if n < m:
					(n, m) = (m, n)
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def MEX(l):
	curr = 0
	l.sort()
	for xorValue in l:
		if xorValue > curr:
			break
		if xorValue == curr:
			curr += 1
	return curr

def grundy(N, M, cache):
	result = []
	if N < M:
		(N, M) = (M, N)
	if (N, M) in cache:
		return cache[N, M]
	if M == 0:
		result.append(N)
	else:
		val = grundy(N % M, M, cache)
		if N >= 2 * M and val != 0:
			val = 0
		result = [val]
	cache[N, M] = MEX(result)
	return cache[N, M]
cache = {}
T = int(input())
for _ in range(T):
	(N, M) = list(map(int, input().split()))
	print('Rich' if grundy(N, M, cache) == 0 else 'Ari')


t = int(input())
for t1 in range(t):
	c = 0
	(x, y) = map(int, input().split())
	while 5:
		if x % y == 0 or y % x == 0 or x <= 0 or (y <= 0):
			break
		if x > y:
			k = x // y
			if k >= 2:
				break
			x = x - k * y
			c = 1 - c
		else:
			k = y // x
			if k >= 2:
				break
			y = y - k * x
			c = 1 - c
	if c == 0:
		print('Ari')
	else:
		print('Rich')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
nb_test = RI()
for _ in range(nb_test):
	(n, m) = RMI()
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		(min_pile, max_pile) = (min(n, m), max(n, m))
		moves = 0
		while True:
			(div, extra) = divmod(max_pile, min_pile)
			moves += 1
			if div > 1:
				break
			else:
				(max_pile, min_pile) = (min_pile, extra)
				if max_pile < min_pile:
					(max_pile, min_pile) = (min_pile, max_pile)
		print(['Ari', 'Rich'][moves % 2 == 0])


for i in range(int(input())):
	(n, m) = map(int, input().split())
	larger_pile = max(m, n)
	smaller_pile = min(m, n)
	count = 0
	while larger_pile % smaller_pile != 0 and larger_pile // smaller_pile == 1:
		(smaller_pile, larger_pile) = (larger_pile % smaller_pile, smaller_pile)
		count += 1
	if count % 2 == 0:
		print('Ari')
	else:
		print('Rich')


def gcd(a, b):
	c = 0
	if b > a:
		(a, b) = (b, a)
	while b:
		t = a // b
		if t > 1:
			return c + 1
		(a, b) = (b, a % b)
		c += 1
	return c
for _ in range(int(input())):
	(a, b) = list(map(int, input().rstrip().split()))
	r = gcd(a, b)
	if r % 2 != 0:
		print('Ari')
	else:
		print('Rich')


t = int(input())
for item in range(t):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	count = 0
	if n % m == 0:
		print('Ari')
	else:
		while True:
			rem = n % m
			que = n // m
			count += 1
			if que > 1:
				break
			else:
				(n, m) = (max(m, rem), min(m, rem))
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	c = 0
	if n % m == 0:
		print('Ari')
	else:
		while True:
			s = n // m
			c = c + 1
			if s > 1:
				break
			else:
				n = n % m
				(n, m) = (max(n, m), min(n, m))
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	cnt = 0
	maxx = max(a, b)
	minn = min(a, b)
	while maxx == maxx % minn + minn:
		if maxx % minn == 0:
			break
		t = minn
		minn = maxx % minn
		maxx = t
		cnt += 1
	if cnt % 2 == 0:
		print('Ari')
	else:
		print('Rich')


def play(a, b, f):
	(a, b) = (min(a, b), max(a, b))
	if b % a == 0:
		return f
	elif b // a > 1:
		return f
	else:
		return play(b % a, a, not f)
t = int(input())
while t > 0:
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	k = play(a, b, True)
	if k:
		print('Ari')
	else:
		print('Rich')
	t -= 1


t = int(input())

def iteration(x):
	a = x[0]
	b = x[1]
	if a < b:
		quotient = b // a
		b = b % a
		c = []
		c.append(a)
		c.append(b)
	else:
		quotient = a // b
		a = a % b
		c = []
		c.append(a)
		c.append(b)
	return (c, quotient)
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	c = []
	c.append(a)
	c.append(b)
	counter = 0
	while c[0] != 0 and c[1] != 0:
		d = iteration(c)
		c = d[0]
		counter = counter + 1
		if d[1] > 1:
			break
	if counter % 2 == 0:
		print('Rich')
	else:
		print('Ari')


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	count = 0
	while x > 0 and y > 0:
		count += 1
		if x > y:
			if x < 2 * y:
				temp = x % y
				if temp == 0:
					x = 0
				else:
					x = temp
			else:
				if count % 2 == 0:
					print('Rich')
				else:
					print('Ari')
				x = 0
		elif x == y:
			if count % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			x = 0
		elif y < 2 * x:
			temp = y % x
			if temp == 0:
				x = 0
			else:
				y = temp
		else:
			if count % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			x = 0
	t -= 1


def Game(P):
	if max(P) % min(P) == 0 or max(P) // min(P) > 1:
		return 0
	else:
		P = [max(P) % min(P), min(P)]
		return 1 + Game(P)
T = int(input())
for _ in range(T):
	P = [int(i) for i in input().split(' ')]
	result = Game(P)
	if result % 2 != 0:
		print('Rich')
	else:
		print('Ari')


t = int(input())
while t:
	(n, m) = list(map(int, input().split()))
	if m % n == 0:
		print('Ari')
	elif n % m == 0:
		print('Ari')
	else:
		small = min(n, m)
		large = max(n, m)
		count = 0
		while True:
			rem = large % small
			quo = large // small
			count += 1
			if quo > 1:
				break
			else:
				large = small
				small = rem
				if large < small:
					(large, small) = (small, large)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	d = 0
	while True:
		if n > m:
			q = n // m
			n -= m * q
			d += 1
			if n == 0 or q > 1:
				break
		elif m > n:
			q = m // n
			m -= n * q
			d += 1
			if m == 0 or q > 1:
				break
		else:
			d += 1
			break
	if d % 2 == 0:
		print('Rich')
	else:
		print('Ari')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	a = max(n, m)
	b = min(n, m)
	(n, m) = (a, b)
	while n != 0 or m != 0:
		if n // m > 1 or m // n > 1 or n % m == 0 or (m % n == 0):
			break
		if n > m:
			n = n % m
		else:
			m = m % n
			(n, m) = (m, n)
		c += 1
	if c % 2 == 0:
		print('Ari')
	else:
		print('Rich')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	count = 0
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		while True:
			(n, m) = (min(n, m), max(n, m))
			q = m // n
			r = m % n
			count += 1
			if q > 1:
				break
			else:
				m = n
				n = r
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def check(a, b, c):
	if a % b == 0 or a // b > 1:
		return c
	else:
		c += 1
		return check(b, a % b, c)
for i in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	a = check(max(n, m), min(n, m), c)
	if a % 2 != 0:
		print('Rich')
	else:
		print('Ari')


def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		if n % m == 0 or m % n == 0:
			print('Ari')
		else:
			count = 0
			while True:
				(n, m) = (min(n, m), max(n, m))
				quoteint = m // n
				remainder = m % n
				count += 1
				if quoteint > 1:
					break
				else:
					m = n
					n = remainder
			if count % 2 == 0:
				print('Rich')
			else:
				print('Ari')
main()


for i in range(0, int(input())):
	(n, m) = map(int, input().split())
	a = min(n, m)
	b = max(n, m)
	count = 0
	flag = 0
	while a != 0:
		if b // a > 1:
			if count % 2 == 0:
				print('Ari')
			else:
				print('Rich')
			flag = 1
			break
		s = b // a
		d = b - s * a
		b = max(d, a)
		a = min(d, a)
		count = count + 1
	if flag == 0:
		if count % 2 != 0:
			print('Ari')
		else:
			print('Rich')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	count = 0
	if max(n, m) % min(n, m) == 0:
		print('Ari')
	else:
		while n > 0 and m > 0:
			if n % m == 0 or m % n == 0:
				count += 1
				break
			if n > m:
				if n // m == 1:
					n -= m
					count += 1
				else:
					count += 1
					break
			elif m // n == 1:
				m -= n
				count += 1
			else:
				count += 1
				break
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	if n % m == 0:
		print('Ari')
	else:
		count = 0
		while True:
			q = n // m
			count += 1
			if q > 1:
				break
			else:
				n = n % m
				(n, m) = (max(n, m), min(n, m))
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	if m > n:
		(n, m) = (m, n)
	if n == 1 or m == 1 or n % m == 0:
		ans = 'Ari'
	else:
		cnt = 0
		while True:
			r = n % m
			q = n // m
			cnt += 1
			if q > 1:
				break
			else:
				n = m
				m = r
				if m > n:
					(n, m) = (m, n)
		if cnt % 2 == 0:
			ans = 'Rich'
		else:
			ans = 'Ari'
	print(ans)


try:
	for i in range(int(input())):
		(n, m) = map(int, input().split())
		c = 0
		b = max(n, m)
		s = min(n, m)
		while b != 0 and s != 0:
			q = b // s
			r = b % s
			c += 1
			if q > 1:
				break
			else:
				s = r
				b = b - s
				if b < s:
					(b, s) = (s, b)
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')
except Exception as e:
	pass


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		count = 0
		smaller = min(m, n)
		larger = max(m, n)
		while True:
			remainder = larger % smaller
			count += 1
			if larger // smaller > 1:
				break
			else:
				larger = smaller
				smaller = remainder
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	(a, r) = (0, 0)
	i = 0
	while n > 0 and m > 0:
		i += 1
		if n > m and n < 2 * m:
			n = n % m
			continue
		elif m > n and m < 2 * n:
			m = m % n
			continue
		else:
			break
	if i % 2 == 0:
		print('Rich')
	else:
		print('Ari')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if n % m == 0:
		print('Ari')
	elif m % n == 0:
		print('Ari')
	else:
		c = 0
		bn = max(n, m)
		sn = min(n, m)
		while True:
			rem = bn % sn
			qu = bn // sn
			c = c + 1
			if qu > 1:
				break
			else:
				sn = rem
				bn = bn - sn
				if bn < sn:
					(bn, sn) = (sn, bn)
		if c % 2 == 0:
			print('Rich')
		else:
			print('Ari')


t = int(input(''))
for m in range(t):
	l = []
	a = input('').split(' ')
	p = int(a[0])
	q = int(a[1])
	if p >= q:
		divisor = q
		dividend = p
	else:
		divisor = p
		dividend = q
	win = 1
	remainder = dividend % divisor
	quotient = int(dividend / divisor)
	l.append(quotient)
	while remainder != 0:
		if quotient != 1:
			break
		else:
			win = win * -1
		dividend = divisor
		divisor = remainder
		remainder = dividend % divisor
		quotient = int(dividend / divisor)
		l.append(quotient)
	if win == 1:
		print('Ari')
	else:
		print('Rich')


for t in range(int(input())):
	(b, s) = map(int, input().split())
	if b < s:
		(b, s) = (s, b)
	c = 0
	while True:
		c = c + 1
		r = b % s
		if r == 0:
			break
		if int(b / s) > 1:
			break
		b = b - s
		if b < s:
			(b, s) = (s, b)
	if c % 2 == 0:
		print('Rich')
	else:
		print('Ari')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	if m % n == 0:
		print('Ari')
	elif n % m == 0:
		print('Ari')
	else:
		s_p = min(m, n)
		l_p = max(m, n)
		count = 0
		while True:
			q = l_p // s_p
			r = l_p % s_p
			count = count + 1
			if q > 1:
				break
			else:
				l_p = s_p
				s_p = r
				if l_p < s_p:
					(l_p, s_p) = (s_p, l_p)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def check(a, b):
	count = 0
	while a > 0 and b > 0:
		count += 1
		if a > b:
			if a < 2 * b:
				r = a % b
				if r == 0:
					a = 0
				else:
					a = r
			else:
				if count % 2 == 0:
					print('Rich')
				else:
					print('Ari')
				a = 0
		elif a == b:
			if count % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			a = 0
		elif b < 2 * a:
			r = b % a
			if r == 0:
				b = 0
			else:
				b = r
		else:
			if count % 2 == 0:
				print('Rich')
			else:
				print('Ari')
			b = 0
n = int(input())
for i in range(n):
	l = list(map(int, input().strip().split()))
	check(l[0], l[1])


t = int(input())
while t:
	(x, y) = map(int, input().split())
	if x == y:
		print('Ari')
	elif x == 1 or y == 1:
		print('Ari')
	else:
		p = 0
		l = []
		while 1:
			if x > y:
				l.append(x // y)
				x = x % y
				p += 1
			if x == 1:
				l.append(y)
				p += 1
				break
			if x == 0:
				break
			if y > x:
				l.append(y // x)
				y = y % x
				p += 1
			if y == 1:
				l.append(x)
				p += 1
				break
			if y == 0:
				break
		c = 1
		for i in range(0, len(l) - 1):
			if l[i] == 1:
				c += 1
			else:
				break
		if c % 2 == 1:
			print('Ari')
		else:
			print('Rich')
	t -= 1


def dmultiple(a, b):
	small = a
	big = b
	big = big % small
	return (big, small)
tcas = int(input())
for i in range(tcas):
	k = list(map(int, input().split()))
	n = k[0]
	m = k[1]
	count = 1
	check = 0
	while n and m and (not check):
		if n >= m:
			if n == m or n / m >= 2:
				count = count
				check = 1
			else:
				count = count + 1
				(m, n) = dmultiple(m, n)
		elif m / n >= 2:
			count = count
			check = 1
		else:
			count = count + 1
			(n, m) = dmultiple(n, m)
	if count % 2 == 1:
		print('Ari')
	else:
		print('Rich')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	k = 0
	while True:
		(m, n) = (max(m, n), min(m, n))
		if m % n == 0 or m // n > 1:
			if k == 0:
				print('Ari')
				break
			else:
				print('Rich')
				break
		else:
			m = m - m // n * n
			k = 1 - k


for _ in range(int(input())):
	(n, m) = [int(z) for z in input().split()]
	if n % m == 0:
		print('Ari')
	elif m % n == 0:
		print('Ari')
	else:
		s = min(n, m)
		l = max(n, m)
		cnt = 0
		while True:
			r = l % s
			q = l // s
			cnt += 1
			if q > 1:
				break
			else:
				l = s
				s = r
				if l < s:
					(l, s) = (s, l)
		if cnt % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def main():
	t = int(input())
	while t:
		t -= 1
		(n, m) = input().split()
		m = int(m)
		n = int(n)
		i = 0
		while n > 0 and m > 0:
			if n / m >= 2 or m / n >= 2:
				i += 1
				break
			elif n > m:
				n = n % m
			else:
				m = m % n
			i += 1
		if i % 2 == 0:
			print('Rich')
		else:
			print('Ari')
main()


t = int(input())
for j in range(t):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	count = 0
	while n > 0 and m > 0:
		if n // m > 1:
			count += 1
			break
		else:
			n = n % m
			count += 1
			(n, m) = (max(n, m), min(n, m))
	if count % 2 == 0:
		print('Rich')
	else:
		print('Ari')


def fun(n, m):
	cnt = 0
	while n > 0 and m > 0:
		if m >= 2 * n or n >= 2 * m:
			cnt += 1
			break
		if m > n:
			m = m % n
			cnt += 1
		else:
			n = n % m
			cnt += 1
	if cnt % 2 == 1:
		return 'Ari'
	else:
		return 'Rich'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	print(fun(n, m))


def jeet(a, b):
	if a < b:
		(a, b) = (b, a)
	if a % b == 0:
		return 1
	elif a - 2 * b > 0:
		return 1
	else:
		return 1 - jeet(a % b, b)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print('Ari' if jeet(a, b) else 'Rich')


def ans(a, b):
	if a == 0:
		return 'Rich'
	elif a == 1 or b >= 2 * a:
		return 'Ari'
	else:
		other = ans(min(a, b - a), max(a, b - a))
		if other == 'Ari':
			return 'Rich'
		else:
			return 'Ari'
T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	print(ans(a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % n == 0 or n % m == 0:
		print('Ari')
	else:
		if n < m:
			(n, m) = (m, n)
		count = 0
		while True:
			remainder = n % m
			quotient = n // m
			count += 1
			if quotient > 1:
				break
			else:
				(n, m) = (m, remainder)
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')


def check(maximum, minimum):
	if maximum % minimum == 0 or maximum // minimum > 1:
		return dp[0]
	else:
		dp[0] += 1
		maximum = maximum - minimum * (maximum // minimum)
		return check(max(maximum, minimum), min(maximum, minimum))
t = int(input())
for _ in range(t):
	dp = [0]
	(a, b) = [int(i) for i in input().split()]
	maximum = max(a, b)
	minimum = min(a, b)
	count = check(maximum, minimum)
	if count % 2 != 0:
		print('Rich')
	else:
		print('Ari')


import collections
import time
import os
import sys
import bisect
import heapq
memo = {}

def solve(n, m):
	if n < m:
		return solve(m, n)
	if m == 0 or n == 0:
		return 0
	if n % m == 0:
		return 1
	key = (n, m)
	if key in memo:
		return memo[key]
	mex = set()
	k = m
	while k <= n:
		mex.add(solve(n - k, m))
		k += m
	res = 0
	while True:
		if res not in mex:
			memo[key] = res
			return res
		res += 1

def f1(n, m):
	if n < m:
		(n, m) = (m, n)
	games = []
	while n and m:
		if n % m == 0:
			games.append(1)
			break
		else:
			games.append(n // m)
		(n, m) = (m, n % m)
	win = False
	for v in reversed(games):
		if not win:
			win = True
		else:
			win = v > 1
	return win
T = int(input())
for ti in range(T):
	(n, m) = map(int, input().split())
	a = f1(n, m)
	if a:
		print('Ari')
	else:
		print('Rich')


import math
import sys
input = sys.stdin.readline

def mapinp():
	return map(int, input().split())

def linp():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = mapinp()
	a = max(n, m)
	b = min(n, m)
	while True:
		temp = a
		z = 0
		if a % b == 0:
			print('Ari')
			break
		for i in range(b, a + 1, b):
			temp = a - i
			if temp < 0:
				break
			if temp % b != 0:
				a = temp
				z = 1
				break
		if z == 0:
			print('Rich')
			break
		else:
			if b % a == 0:
				print('Rich')
				break
			z = 0
			temp = b
			for i in range(a, b + 1, a):
				temp = b - i
				if temp < 0:
					break
				if temp % a != 0:
					b = temp
					z = 1
					break
			if z == 0:
				print('Ari')
				break


t = int(input())
for i in range(t):
	q = input().split()
	n = int(q[0])
	m = int(q[1])
	turn = 1
	l = []
	f = 0
	if n % m == 0 or m % n == 0:
		print('Ari')
	else:
		while n != 1 or m != 1:
			l = []
			turn = turn * -1
			if n % m == 0 or m % n == 0:
				if turn == -1:
					print('Ari')
				else:
					print('Rich')
				break
			if n > m:
				b = n
				s = m
			else:
				b = m
				s = n
			for j in range(1, b // s + 1):
				l.append(j * s)
				if len(l) > 1:
					if turn == -1:
						print('Ari')
					else:
						print('Rich')
					f = 1
					break
			if f == 1:
				break
			if len(l) == 1:
				if n > m:
					n = n - l[-1]
				else:
					m = m - l[-1]


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().strip().split())
	c = 0
	l = []
	while a != 0 and b != 0:
		t1 = min(a, b)
		t2 = max(a, b)
		te = t2 / t1
		if te == int(te):
			l.append(1)
		else:
			te = int(te)
			l.append(te)
		if t1 == a:
			b -= t1 * te
		else:
			a -= t1 * te
		c += 1
	le_l = len(l)
	for i in range(le_l - 1, -1, -1):
		if l[i] > 1:
			if i % 2 == 0:
				if c % 2 == 0:
					c += 1
			elif c % 2 == 1:
				c += 1
	if c % 2 == 1:
		print('Ari')
	else:
		print('Rich')


import sys

def fun(a, b):
	if a % b == 0 or a // b > 1:
		return count[0]
	else:
		count[0] += 1
		a -= b * (a // b)
		return fun(max(a, b), min(a, b))
for _ in range(int(sys.stdin.readline())):
	count = [0]
	(c, d) = [int(i) for i in sys.stdin.readline().split()]
	(a, b) = (max(c, d), min(c, d))
	count = fun(a, b)
	if count % 2 != 0:
		print('Rich')
	else:
		print('Ari')


t = int(input())
for t_i in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	if m > n:
		(m, n) = (n, m)
	aWinner = True
	while True:
		if n % m == 0 or n / m >= 2:
			break
		else:
			n = n % m
			if m % n == 0 or m / n >= 2:
				aWinner = not aWinner
				break
			m = m % n
	if aWinner:
		print('Ari')
	else:
		print('Rich')


T = int(input())

def printAns(j):
	if j % 2 == 0:
		print('Rich')
	else:
		print('Ari')
for i in range(T):
	(n, m) = map(int, input().split(' '))
	a = max(n, m)
	b = min(n, m)
	j = 0
	while True:
		j += 1
		mx = max(a, b)
		b = min(a, b)
		a = mx
		if a % b == 0:
			printAns(j)
			break
		elif int(a / b) >= 2:
			printAns(j)
			break
		else:
			a = a % b


import sys
sys.setrecursionlimit(1001)
t = int(input())
for i in range(t):
	(m, n) = [int(x) for x in input().split()]
	x = 0
	while m != 0 and n != 0:
		x = x + 1
		if m > n:
			if int(m / n) == 1:
				m = m - n
			elif m % n == 0:
				m = 0
			else:
				break
		elif n >= m:
			if int(n / m) == 1:
				n = n - m
			elif n % m == 0:
				n = 0
			else:
				break
	if x % 2 != 0:
		print('Ari')
	else:
		print('Rich')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	mx = n if n >= m else m
	mn = m if m <= n else n
	x = 1
	count = 0
	if mx // mn == 1 and mx % mn != 0:
		while n > 0 and m > 0 and (x == 1):
			count = count + 1
			if n > m:
				x = n // m
				n = n - m * x
			else:
				x = m // n
				m = m - x * n
		if count % 2 == 0:
			print('Rich')
		else:
			print('Ari')
	else:
		print('Ari')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	flag = 'Ari'
	c = 0
	flag1 = 0
	while 1:
		(a, b) = (max(a, b), min(a, b))
		if a % b == 0 or a // b > 1:
			break
		if a // b == 1:
			a -= b
		if flag == 'Ari':
			flag = 'Rich'
		else:
			flag = 'Ari'
	print(flag)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	winner = 'Ari'
	while n > 0 and m > 0:
		if n == m:
			break
		if n >= 2 * m or m >= 2 * n:
			break
		else:
			if m > n:
				m = m - n
			else:
				n = n - m
			if winner == 'Ari':
				winner = 'Rich'
			else:
				winner = 'Ari'
	print(winner)


def gamegcd(n, m):
	a = 0
	l = []
	while m:
		if n > m:
			if n % m == 0:
				m = 0
				a = 1
				l.append(a)
			else:
				a = int(n // m)
				n %= m
				l.append(a)
		elif m % n == 0:
			m = 0
			a = 1
			l.append(a)
		else:
			a = int(m // n)
			m %= n
			l.append(a)
	return l
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == m:
		print('Ari')
	else:
		if n > m:
			l = gamegcd(n, m)
		else:
			l = gamegcd(m, n)
		length = len(l)
		f = True
		for x in range(length):
			if l[x] > 1:
				f = False
				if (x + 1) % 2 == 0:
					print('Rich')
				else:
					print('Ari')
				break
		if f:
			print('Rich' if length % 2 == 0 else 'Ari')