Louise and Richard have developed a numbers game.  They pick a number and check to see if it is a power of $2$.  If it is, they divide it by $2$.  If not, they reduce it by the next lower number which is a power of $2$.  Whoever reduces the number to $1$ wins the game.  Louise always starts.

Given an initial value, determine who wins the game.

Example 

$n=132$   

It's Louise's turn first.  She determines that $132$ is not a power of $2$.  The next lower power of $2$ is $\textbf{128}$, so she subtracts that from $132$ and passes $4$ to Richard.  $4$ is a power of $2$, so Richard divides it by $2$ and passes $2$ to Louise.  Likewise, $2$ is a power so she divides it by $2$ and reaches $1$.  She wins the game.

Update If they initially set counter to $1$, Richard wins.  Louise cannot make a move so she loses.

Function Description  

Complete the counterGame function in the editor below.  

counterGame has the following parameter(s):  

int n: the initial game counter value  

Returns   

string: either Richard or Louise

Input Format

The first line contains an integer $\boldsymbol{\boldsymbol{t}}$, the number of testcases. 

Each of the next $\boldsymbol{\boldsymbol{t}}$ lines contains an integer $n$, the initial value for each game.  

Constraints

$1\leq t\leq10$
$1\leq n\leq2^{64}-1$

Sample Input 0
1
6

Sample Output 0
Richard

Explanation 0

$\boldsymbol{6}$ is not a power of $2$ so Louise reduces it by the largest power of $2$ less than $\boldsymbol{6}$:$6-4=2$.  
$2$ is a power of $2$ so Richard divides by $2$ to get $1$ and wins the game.

Difficulty: MEDIUM
Tags: Bit manipulation
Skill types: Bit manipulation

Starter code:

Solutions:
import math
from math import log2
from math import floor

def genlist(x):
	if x == 1:
		return False
	elif log2(x) % 1 == 0:
		return not genlist(int(x / 2))
	else:
		return not genlist(x - 2 ** floor(log2(x)))
tcs = int(input())
for tc in range(tcs):
	sa = int(input())
	if genlist(sa):
		print('Louise')
	else:
		print('Richard')


def f(x):
	if x == 1:
		return False
	if x & x - 1 == 0:
		return not f(x >> 1)
	else:
		return not f(int(bin(x)[3:], 2))
t = int(input())
for _ in range(t):
	print('Louise' if f(int(input())) else 'Richard')


def f(n):
	ret = 1
	while ret <= n:
		ret *= 2
	return ret // 2
for t in range(int(input())):
	(n, k) = (int(input()), 0)
	while True:
		if n == 1:
			break
		if f(n) == n:
			n //= 2
		else:
			n -= f(n)
		k ^= 1
	print('Richard' if not k else 'Louise')


T = int(input())
for t in range(T):
	N = int(input())
	ans = 0
	while N > 1:
		b = 1
		while b * 2 < N:
			b *= 2
		N -= b
		ans += 1
	if ans % 2 == 0:
		print('Richard')
	else:
		print('Louise')


a = 'Louise'
b = 'Richard'
d = int(input())

def ispower(n):
	for i in range(1, 65):
		if n == pow(2, i):
			return True
	return False

def powto(n):
	if not ispower(n):
		for i in range(1, 65):
			if n - pow(2, i) < 0:
				return pow(2, i - 1)
for e in range(d):
	c = 1
	f = int(input())
	while f != 1:
		c = c + 1
		if ispower(f):
			f = int(f / 2)
		else:
			f = f - powto(f)
	if c % 2 == 0:
		print(a)
	else:
		print(b)


t = int(input())
for i in range(t):
	val = int(input())
	bin_string = bin(val)[2:]
	if val == 1:
		print('Richard')
		continue
	moves = 0
	while True:
		bin_len = len(bin_string)
		num_zeros = sum((1 for val in bin_string if val == '0'))
		if num_zeros == bin_len - 1:
			if (moves + bin_len) % 2 == 1:
				print('Richard')
			else:
				print('Louise')
			break
		else:
			bin_string = bin_string[1:]
			bin_string = bin_string.lstrip('0')
			moves += 1


def one_places(N):
	b_str = bin(N)[2:]
	return [idx for (idx, c) in enumerate(reversed(b_str)) if c == '1']

def game_result(N):
	op = one_places(N)
	return (len(op) - 1 + op[0]) % 2
_players = ('Richard', 'Louise')
T = int(input())
for _ in range(T):
	N = int(input())
	print(_players[game_result(N)])


from sys import stdin
from math import log
T = int(stdin.readline())
for _ in range(T):
	N = int(stdin.readline())
	a = 0
	while N > 1:
		a += 1
		m = int(log(N, 2))
		if N == 2 ** m:
			N /= 2
		else:
			N -= 2 ** m
	if a % 2 == 1:
		print('Louise')
	else:
		print('Richard')


def findFirstOneFromLeft(N):
	for i in range(63, -1, -1):
		if N >> i & 1 == 1:
			return i

def play(N):
	i = findFirstOneFromLeft(N)
	if N == 1 << i:
		return N >> 1
	else:
		return N & ~(1 << i)

def win(N):
	flag = 1
	while N != 1:
		N = play(N)
		flag = 1 - flag
	if flag:
		print('Richard')
	else:
		print('Louise')
T = int(input())
for _ in range(T):
	win(int(input()))


def pow3(a):
	z = 1
	while 2 * z < a:
		z *= 2
	return z
r = int(input(''))
for g in range(r):
	turn = 'Louise'
	x = int(input(''))
	z = x
	while True:
		if z == 1:
			if turn == 'Louise':
				print('Richard')
				break
			else:
				print('Louise')
				break
		z -= pow3(z)
		if turn == 'Louise':
			turn = 'Richard'
		else:
			turn = 'Louise'


def isp2(val):
	if not val % 2 == 0:
		return 0
	if val == 2:
		return 1
	while val > 0:
		val = val / 2
		if val == 2:
			return 1
	return 0

def findPower(previous, goal):
	if previous * 2 > goal:
		return previous
	else:
		return findPower(previous * 2, goal)
testcases = int(input())
for _ in range(testcases):
	counter = int(input())
	turns = 1
	while not counter == 1:
		if isp2(counter) == 1:
			counter = counter / 2
		else:
			counter -= findPower(1, counter)
		turns += 1
	if turns % 2 == 0:
		print('Louise')
	else:
		print('Richard')


inputno = int(input())
cases = []
while inputno > 0:
	inputno -= 1
	val = int(input())
	cases.append(val)

def fiddle(num):
	binnum = bin(int(num))
	strlen = len(binnum) - 2
	string = '0b1' + '0' * (strlen - 1)
	if binnum == string:
		return num / 2
	intofstring = int(string, 2)
	laststring = int(binnum, 2) & intofstring
	return int(num - laststring)

def winner(case):
	if case == 1:
		return 0
	return int(winner(fiddle(case)) + 1)
for case in cases:
	if winner(case) % 2 == 0:
		print('Richard')
	else:
		print('Louise')


T = int(input())
for i in range(T):
	N = int(input())
	bits = list(bin(N))[2:]
	p = ['Louise', 'Richard']
	bit_count = bits.count('1')
	right_zeros = bits[::-1].index('1')
	print(p[(bit_count + right_zeros) % 2])


import math

def num(str, n):
	if n == 0:
		print(str)
		return
	elif n & n - 1 == 0:
		n = n / 2
	else:
		n = n - 2 ** int(math.log(n, 2))
	if str == 'Louise':
		num('Richard', int(n))
	else:
		num('Louise', int(n))
for i in range(int(input())):
	num('Louise', int(input()))


import math
t = int(input())
while t:
	c = 0
	n = int(input())
	while n > 1:
		if n and (not n & n - 1):
			u = 0
			while n != 1:
				n = n >> 1
				u = u + 1
			c = c + u
			break
		else:
			k = n
			k = int(k)
			i = 0
			while pow(2, i) < n:
				k = pow(2, i)
				i = i + 1
			n = n - k
			c = c + 1
	t = t - 1
	if c == 0:
		print('Louise')
	elif c % 2 != 0:
		print('Louise')
	else:
		print('Richard')


from math import sqrt, modf

def isPower2(n):
	if n == 2:
		return True
	elif n < 2:
		return False
	return isPower2(n / 2)

def power2to(N):
	i = 2
	lastIndex = 2
	while i < N:
		lastIndex = i
		i *= 2
	return lastIndex

def tour(N, joueur):
	if N == 1:
		return (joueur + 1) % 2
	if isPower2(N):
		N /= 2
	else:
		N -= power2to(N)
	return tour(N, (joueur + 1) % 2)
T = int(input())
result = list()
for i in range(T):
	N = int(input())
	if tour(N, 0) == 0:
		result.append('Louise')
	else:
		result.append('Richard')
print('\n'.join(result))


twosList = list(reversed([2 ** i for i in range(64)]))
twosSet = {2 ** i for i in range(64)}

def powerOfTwo(n):
	for e in twosList:
		if e < n:
			return e
N = int(input())
for numTest in range(N):
	curr = int(input())
	ops = 0
	while curr != 1:
		if curr in twosSet:
			curr /= 2
		else:
			curr = curr - powerOfTwo(curr)
		ops += 1
	if ops % 2 == 0:
		print('Richard')
	else:
		print('Louise')


def findFirstOneFromLeft(N):
	for i in range(63, -1, -1):
		if N >> i & 1 == 1:
			return i

def play(N):
	i = findFirstOneFromLeft(N)
	if N == 1 << i:
		return N >> 1
	else:
		return N & ~(1 << i)

def win(N):
	flag = 1
	while N != 1:
		N = play(N)
		flag = 1 - flag
	if flag:
		print('Richard')
	else:
		print('Louise')
T = int(input())
for _ in range(T):
	win(int(input()))


def solve(n):
	powersOfTwo = set()
	for x in range(64):
		powersOfTwo.add(1 << x)
	steps = 0
	while n > 1:
		steps += 1
		if not n in powersOfTwo:
			largestPower = 1
			currentPower = 1
			t = n
			while t > 0:
				if t & 1:
					largestPower = currentPower
				t >>= 1
				currentPower <<= 1
			n = n - largestPower
		else:
			n >>= 1
	return 'Louise' if steps % 2 == 1 else 'Richard'
t = int(input())
for i in range(0, t):
	n = int(input())
	print(solve(n))


def testpower(n):
	power = False
	t = 1
	while t < n:
		t <<= 1
	if t == n:
		power = True
	return (power, t >> 1)
T = int(input())
for _ in range(T):
	n = int(input())
	p = 0
	while n ^ 1:
		(power, below) = testpower(n)
		if power:
			n >>= 1
		else:
			n -= below
		p += 1
	if p & 1:
		print('Louise')
	else:
		print('Richard')


t = int(input())
for i in range(t):
	n = int(input())
	x = bin(n)[2:]
	c = 0
	while len(x) > 1:
		if x[1:].count('1') == 0:
			x = x[:len(x) - 1]
		else:
			x = x[1:]
			while x[0] == '0':
				x = x[1:]
		c = (c + 1) % 2
	if c == 1:
		print('Louise')
	else:
		print('Richard')


def CountMoves(N):
	C = 0
	while N > 1 and N % 2 == 0:
		N = N // 2
		C = C + 1
	while N > 1:
		r = N % 2
		if r == 1:
			C = C + 1
		N = (N - r) // 2
	return C
T = int(input())
while T:
	T = T - 1
	N = int(input())
	Moves = CountMoves(N)
	if Moves % 2 == 0:
		print('Richard')
	else:
		print('Louise')


for _ in range(int(input())):
	a = int(input())
	c = 1
	while a & 1 == 0:
		c ^= 1
		a >>= 1
	while a:
		if a & 1:
			c ^= 1
		a >>= 1
	print('Louise' if c else 'Richard')


import math

def foo(x):
	count = 0
	cone = 0
	while x > 0:
		if x % 2 == 1:
			cone += 1
		count += 1
		x //= 2
	l = []
	l.append(count)
	l.append(cone)
	return l
test = int(input())
for i in range(test):
	x = int(input())
	y = x
	countn = 0
	while True:
		u = foo(x)
		if u[1] == 1:
			break
		else:
			x = x - pow(2, foo(x)[0] - 1)
			countn += 1
			if x == 0:
				break
	q = foo(x)[0]
	countn += q - 1
	if countn % 2 == 1:
		print('Louise')
	else:
		print('Richard')


for x in range(int(input())):
	n = int(input())
	a = bin(n)[2:]
	o = 0
	while len(a) > 0:
		if a[1:].count('1') == 0:
			a = a[:len(a) - 1]
		else:
			a = a[1:]
			while a[0] == '0':
				a = a[1:]
		o += 1
	if o % 2 == 1:
		print('Richard')
	else:
		print('Louise')


def counter():
	T = int(input())
	for t in range(0, T):
		N = int(input())
		binN = '{0:b}'.format(N)
		lenBinN = len(binN)
		if binN.count('1') == 1:
			if lenBinN % 2 == 0:
				print('Louise')
			else:
				print('Richard')
		else:
			flag = True
			while 1:
				binN = binN[1:]
				binN = binN[binN.find('1'):]
				flag = not flag
				lenBinN = len('{0:b}'.format(int(binN, 2)))
				if binN.count('1') == 1:
					if flag:
						if lenBinN % 2 == 0:
							print('Louise')
						else:
							print('Richard')
					elif lenBinN % 2 == 0:
						print('Richard')
					else:
						print('Louise')
					break
				N = int(binN, 2)
counter()


class Game(object):

	def __init__(self, initialvalue):
		self.counter = initialvalue
		self.turn = 'Richard'

	def play(self):
		while not self.winner:
			if self._pow2(self.counter):
				self.reduce_by_half()
			else:
				self.reduce_by_pow2()
		return self.winner

	def reduce_by_half(self):
		self.flip()
		self.counter = self.counter >> 1

	def reduce_by_pow2(self):
		self.flip()
		self.counter -= 1 << self._hiset(self.counter)

	@property
	def winner(self):
		if self.counter == 1:
			return self.turn
		else:
			return False

	def flip(self):
		if self.turn == 'Louise':
			self.turn = 'Richard'
		else:
			self.turn = 'Louise'

	def _pow2(self, a):
		return a != 1 and a & a - 1 == 0

	def _testbit(self, a, bit):
		return a & 1 << bit != 0

	def _hiset(self, a):
		bit = int.bit_length(a)
		while not self._testbit(a, bit):
			bit -= 1
		return bit

def main():
	testcount = int(input())
	while testcount > 0:
		game = Game(int(input()))
		print(game.play())
		testcount -= 1
main()


tests = int(input())
for _ in range(tests):
	n = int(input())
	iterations = 0
	while n > 1:
		iterations += 1
		n = n >> 1 if not n & n - 1 else n - 2 ** (n.bit_length() - 1)
	print('Richard' if not iterations & 1 else 'Louise')


def isPowerOf2(N):
	M = N
	n1 = 0
	for i in range(64):
		if M & 1 == 1:
			n1 += 1
		M = M >> 1
	return n1 == 1

def reduceByLargestPowerOf2LessThanN(N):
	M = N
	i = 0
	while M != 1:
		i += 1
		M = M >> 1
	mask = 2 ** i
	return N ^ mask

def halveN(N):
	return N >> 1
numTests = int(input())
for i in range(numTests):
	N = int(input())
	towin = 'Richard'
	while N > 1:
		if isPowerOf2(N):
			N = halveN(N)
		else:
			N = reduceByLargestPowerOf2LessThanN(N)
		towin = 'Louise' if towin == 'Richard' else 'Richard'
	print(towin)


def butt(n):
	i = 0
	c = 0
	h = 0
	while n:
		if n & 1:
			c += 1
			h = i
		n >>= 1
		i += 1
	return (c, h)
T = int(input())
for _ in range(T):
	N = int(input())
	c = 0
	dudes = ['Richard', 'Louise']
	while N > 1:
		(num_bits, highest_bit) = butt(N)
		if num_bits == 1:
			N >>= 1
		else:
			N -= 2 ** highest_bit
		c += 1
	print(dudes[c % 2])


def is_power_of_2(n):
	return n & n - 1 == 0

def largest_p2_less(n):
	b = 1
	while b < n:
		b <<= 1
	return b >> 1
t = int(input())
for i in range(t):
	turn = 0
	n = int(input())
	c = n
	if c == 1:
		print('Richard')
	else:
		while c != 1:
			if is_power_of_2(int(c)):
				c /= 2
			else:
				c -= largest_p2_less(c)
			turn ^= 1
		if turn == 0:
			print('Richard')
		else:
			print('Louise')


cases = int(input())
s = {0: 'Richard', 1: 'Louise'}

def solve(n):
	c = 0
	while n != 1:
		c += 1
		if n % 2 == 0:
			n >>= 1
		else:
			sub = 1 << len(str(bin(n))) - 3
			n -= sub
	print(s[c % 2])
for case in range(cases):
	n = int(input())
	solve(n)


def get_winner(num):
	binary = bin(num)[2:]
	num_ones = binary.count('1')
	num_trailing_zeros = len(binary.split('1')[-1])
	num_turns = num_ones - 1 + num_trailing_zeros
	if num_turns % 2 == 1:
		return 'Louise'
	else:
		return 'Richard'
num = int(input())
for counter_i in range(num):
	counter = int(input())
	print(get_winner(counter))


two_powers = [1 << i for i in range(64)]

def moves(n):
	if n == 1:
		return 0
	elif n in two_powers:
		return 1 + moves(n // 2)
	else:
		largest_power = 0
		for i in reversed(range(len(two_powers))):
			if n > two_powers[i]:
				largest_power = two_powers[i]
				break
		return 1 + moves(n - largest_power)
for _ in range(int(input())):
	if moves(int(input())) % 2 == 0:
		print('Richard')
	else:
		print('Louise')


T = int(input())
for i in range(T):
	N = int(input())
	richard = True
	while N > 1:
		richard = not richard
		k = 1
		while 2 * k < N:
			k = k * 2
		N = N - k
	if richard:
		print('Richard')
	else:
		print('Louise')


T = int(input())
winner = 0

def is_power2(num):
	return num != 0 and num & num - 1 == 0

def powerof2(num):
	i = 0
	while i <= 64:
		if int(num / pow(2, i)) == 0:
			return i
		else:
			i = i + 1
for i in range(0, T):
	Number = int(input())
	winner = 0
	if Number == 1:
		print('Louise')
		continue
	if is_power2(Number) == 1:
		Number = int(Number - Number / 2)
	else:
		Number = Number - pow(2, powerof2(Number) - 1)
	while Number > 1:
		winner = ~winner
		if is_power2(Number) == 1:
			Number = int(Number - Number / 2)
		else:
			Number = Number - pow(2, powerof2(Number) - 1)
	if winner == 0:
		print('Louise')
	else:
		print('Richard')


def is_power_of_two(n):
	return n != 0 and n & n - 1 == 0

def highest_power_of_two(n):
	n = n | n >> 1
	n = n | n >> 2
	n = n | n >> 4
	n = n | n >> 8
	n = n | n >> 16
	return n - (n >> 1)
t = int(input())
for i in range(t):
	n = int(input())
	louise = True
	while n != 1:
		if is_power_of_two(n):
			n = n // 2
		else:
			n -= highest_power_of_two(n)
		louise = not louise
	if louise:
		print('Richard')
	else:
		print('Louise')


for i in range(0, int(input())):
	rWins = True
	num = int(input())
	while num != 1:
		if num & num - 1 == 0:
			if (len(bin(num)) - 3) % 2 == 0:
				break
			else:
				rWins = not rWins
				break
		else:
			rWins = not rWins
			num -= int(2 ** (len(bin(num)) - 3))
	if rWins:
		print('Richard')
	else:
		print('Louise')


for i in range(int(input())):
	n = int(input())
	binary = str(bin(n))[-1:1:-1]
	count1 = binary.count('1')
	count2 = binary.index('1')
	print('Richard' if (count1 + count2) % 2 == 1 else 'Louise')


from math import log2

def game(n):
	bn = list(bin(n)[2:])
	ops = 0
	while len(bn) > 1:
		ops += 1
		if bn.count('1') > 1:
			while True:
				bn.pop(0)
				if bn and bn[0] == '1':
					break
		else:
			bn.pop()
	return 'Louise' if ops % 2 else 'Richard'
T = int(input())
for x in range(T):
	print(game(int(input())))


import sys

def run_tests():
	T = sys.stdin.readline()
	for i in range(int(T)):
		determine_winner(int(sys.stdin.readline()))

def determine_winner(N):
	lastMoveLouise = False
	while N != 1:
		if N & N - 1 == 0:
			N >>= 1
		else:
			N -= 1 << get_highest_bit_position(N) - 1
		lastMoveLouise = not lastMoveLouise
	winner = 'Louise' if lastMoveLouise else 'Richard'
	sys.stdout.write(winner + '\n')

def get_highest_bit_position(n):
	counter = 0
	while n != 0:
		counter += 1
		n >>= 1
	return counter
run_tests()


lst = [2 ** i for i in range(65)]
for i in range(int(input())):
	n = int(input())
	counter = 0
	while n != 1:
		j = 0
		while lst[j + 1] < n:
			j += 1
		n -= lst[j]
		counter += 1
	if counter % 2 == 0:
		print('Richard')
		continue
	print('Louise')


def counterGame(n):
	fs = bin(n)[2:]
	total = 0
	i = len(fs) - 1
	while i != -1:
		if fs[i] != '0':
			break
		i -= 1
	total += len(fs) - i - 1 + fs[:i].count('1')
	if total & 1:
		print('Louise')
	else:
		print('Richard')

def main():
	t = int(input())
	while t != 0:
		n = int(input())
		counterGame(n)
		t -= 1
main()


for t in range(int(input())):
	n = int(input())
	b = bin(n)
	i = b.count('1')
	j = len(b.split('1')[-1])
	if (i + j) % 2 == 0:
		print('Louise')
	else:
		print('Richard')


T = int(input())
for _ in range(T):
	N = int(input())
	one = 1 << 63
	count = 0
	while N > 1:
		while one > N:
			one >>= 1
		if N == one:
			N >>= 1
		else:
			N -= one
		count += 1
	if count % 2 == 0:
		print('Richard')
	else:
		print('Louise')


import sys
t = int(sys.stdin.readline().strip())
for tests in range(t):
	n = int(sys.stdin.readline().strip())
	turns = 0
	while n > 1:
		msb = 1 << len(bin(n)) - 3
		if msb & n - 1 == 0:
			n = n >> 1
		else:
			n = n - msb
		turns += 1
	if turns % 2 == 0:
		print('Richard')
	else:
		print('Louise')


T = int(input())
for i in range(T):
	N = int(input())
	n = 0
	while N > 1:
		count = bin(N).count('1')
		if count == 1:
			N = int(N / 2)
		else:
			N = N - pow(2, len(bin(N)) - 3)
		n = (n + 1) % 2
	if n == 0:
		print('Richard')
	else:
		print('Louise')


def cntAlt(n):
	c = 0
	while n != 1:
		t = 1
		while t < n:
			t <<= 1
		n -= t >> 1
		c += 1
	return c
for i in range(int(input())):
	print('Richard' if cntAlt(int(input())) % 2 == 0 else 'Louise')


import math

def check_power(n):
	if n & n - 1 == 0:
		return True
	else:
		return False

def closest_power(n):
	power = math.log2(n)
	power = math.floor(power)
	return 2 ** power
T = int(input())
for i in range(T):
	inp = int(input())
	counter = 0
	while inp != 1:
		if check_power(inp) == True:
			counter += math.log2(inp)
			break
		else:
			inp = inp - closest_power(inp)
			counter += 1
	if counter % 2 == 0:
		print('Richard')
	else:
		print('Louise')


arr_2_power = [None] * 65
for i in range(1, 65):
	arr_2_power[i] = 2 ** i
T = int(input())
for t in range(T):
	counter = int(input())
	turn = 0
	while counter != 1:
		turn += 1
		if counter in arr_2_power:
			counter = counter // 2
		else:
			for i in range(1, 65):
				if arr_2_power[i] > counter:
					counter -= arr_2_power[i - 1]
					break
	if turn % 2 == 0:
		print('Richard')
	else:
		print('Louise')


t = int(input())
while t > 0:
	n = int(input())
	x = bin(n)[2:]
	winner = 0
	while len(x) > 1:
		if x[1:].count('1') == 0:
			x = x[:len(x) - 1]
		else:
			x = x[1:]
			while x[0] == '0':
				x = x[1:]
		winner = (winner + 1) % 2
	if winner == 1:
		print('Louise')
	else:
		print('Richard')
	t -= 1


def nextPowerOf2(n):
	n = n - 1
	n = n | n >> 1
	n = n | n >> 2
	n = n | n >> 4
	n = n | n >> 8
	n = n | n >> 16
	n = n + 1
	return n

def main():
	tt = int(input())
	num = []
	name = []
	for i in range(tt):
		a = int(input())
		num.append(a)
	for i in range(tt):
		c = 1
		counter = num[i]
		while counter != 1:
			a = nextPowerOf2(counter)
			if a != counter:
				a = a // 2
			else:
				a = counter // 2
			counter = counter - a
			c = c + 1
		c = c - 1
		if c % 2 == 0:
			name.append('Richard')
		else:
			name.append('Louise')
	for i in range(tt):
		print(name[i])
main()


def solve(N):
	c0 = 0
	while N > 0 and (not N & 1):
		c0 += 1
		N >>= 1
	c1 = 0
	while N > 0:
		if N & 1:
			c1 += 1
		N >>= 1
	if (c0 + c1) % 2 == 0:
		return 'Louise'
	else:
		return 'Richard'
T = int(input())
for _ in range(T):
	N = int(input())
	print(solve(N))


from math import floor, log
t = int(input().strip())

def get_count(n):
	assert n >= 1
	cnt = 0
	eps = 0.01
	if n == 1:
		return 0
	if n - 2 ** floor(log(n, 2)) < eps:
		cnt = floor(log(n, 2))
	else:
		cnt = 1 + get_count(n - 2 ** floor(log(n, 2)))
	return cnt
for i in range(t):
	n = int(input().strip())
	cnt = get_count(n)
	if cnt % 2 == 0:
		print('Richard')
	else:
		print('Louise')


def moves(n):
	res = 0
	while n % 2 == 0:
		res += 1
		n //= 2
	while n != 1:
		if n % 2 == 1:
			res += 1
		n //= 2
	return res
for _ in range(int(input())):
	n = int(input())
	print('Richard' if moves(n) % 2 == 0 else 'Louise')


n = int(input())
for i in range(n):
	turns = 0
	x = bin(int(input()))
	if False:
		print('Richard')
	else:
		turns += x.count('1') - 1
		turns += len(x.split('1')[-1])
		print('Louise' if turns % 2 == 1 else 'Richard')


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	m = 0
	while n > 1:
		i = 0
		k = 0
		while n >> i > 0:
			k = k + (n >> i & 1)
			i = i + 1
		if k == 1:
			n = n >> 1
		else:
			n = n - (1 << i - 1)
		m = m + 1
	if m == 0 or m & 1 == 1:
		print('Louise')
	else:
		print('Richard')


t = int(input())
while t:
	c = 0
	n = int(input())
	while n > 1:
		if n and (not n & n - 1):
			u = 0
			while n != 1:
				n = n >> 1
				u = u + 1
			c = c + u
			break
		else:
			k = n
			k = int(k)
			i = 0
			while pow(2, i) < n:
				k = pow(2, i)
				i = i + 1
			n = n - k
			c = c + 1
	t = t - 1
	if c == 0:
		print('Louise')
	elif c % 2 != 0:
		print('Louise')
	else:
		print('Richard')


def is_power_of_two(n):
	return n & n - 1 == 0 and n > 0

def largest_power(n):
	res = 1
	while res < n:
		res <<= 1
	return res >> 1

def whois_winner(n):
	winner = 0
	while n != 1:
		if is_power_of_two(n):
			n >>= 1
			winner ^= 1
		else:
			n -= largest_power(n)
			winner ^= 1
	return 'Louise' if winner else 'Richard'

def main():
	t = int(input())
	for x in range(t):
		print(whois_winner(int(input())))
main()


for t in range(int(input())):
	(n, z) = (int(input()), False)
	while n > 1:
		if n & n - 1 == 0:
			n = n >> 1
		else:
			(t, c) = (n, 0)
			while t > 0:
				(t, c) = (t >> 1, c + 1)
			n = n - (1 << c - 1)
		z = not z
	if z:
		print('Louise ')
	else:
		print('Richard ')


t = int(input())
for i in range(t):
	n = int(input())
	end = n & -n
	turns = bin(n - end).count('1') + bin(end).count('0') - 1
	print('Richard Louise'.split()[turns % 2])


for _ in range(int(input())):
	N = int(input()) - 1
	N = (N & 6148914691236517205) + (N >> 1 & 6148914691236517205)
	N = (N & 3689348814741910323) + (N >> 2 & 3689348814741910323)
	N = (N & 1085102592571150095) + (N >> 4 & 1085102592571150095)
	N = (N & 71777214294589695) + (N >> 8 & 71777214294589695)
	N = (N & 281470681808895) + (N >> 16 & 281470681808895)
	N = (N & 4294967295) + (N >> 32 & 4294967295)
	print('Richard' if N % 2 == 0 else 'Louise')


for _ in range(int(input())):
	num = int(input())
	turns = 0
	while num != 1:
		low = 1
		while low * 2 <= num:
			low *= 2
		if low == num:
			num = num // 2
		else:
			num -= low
		turns += 1
	print('Richard' if turns % 2 == 0 else 'Louise')


def ans(n):
	p = 1
	while n > p:
		p <<= 1
	p >>= 1
	return n - p
z = int
a = input
p = print
t = z(a())
while t:
	t -= 1
	c = 0
	n = z(a())
	while n > 1:
		p = n & n - 1
		if p == 0:
			n >>= 1
		else:
			n = ans(n)
		c += 1
	if c % 2 == 0:
		print('Richard')
	else:
		print('Louise')


def makeMove(n):
	if n <= 1:
		return None
	nb = n
	(i, ones) = (0, 0)
	while nb > 0:
		if nb & 1:
			ones += 1
		i += 1
		nb >>= 1
	if ones > 1:
		return n - (1 << i - 1)
	else:
		return n >> 1

def playBall(n):
	rounds = 0
	while n:
		n = makeMove(n)
		if n:
			rounds += 1
	if rounds % 2:
		return 'Louise'
	else:
		return 'Richard'
tcs = int(input().strip())
for i in range(0, tcs):
	print(playBall(int(input().strip())))


import math

def pwr(n):
	if n == 1:
		return True
	if n == 0 or n % 2 != 0:
		return False
	return pwr(n / 2)
t = int(input())
for _ in range(t):
	n = int(input())
	cnt = 0
	while n != 1:
		if pwr(n) == True:
			n = n / 2
		else:
			p = int(math.log(n, 2))
			p = 2 ** p
			n = n - p
		cnt += 1
	if cnt % 2 == 0:
		print('Richard')
	else:
		print('Louise')


def counter_game(c):
	i = 0
	while int(c) > 1:
		tmp = '1' + '0' * (len(c) - 1)
		if c == tmp:
			c = tmp[:-1]
		else:
			c = bin(int(c, 2) - int(tmp, 2)).lstrip('0b')
		i += 1
	if i % 2 == 0:
		print('Richard')
	else:
		print('Louise')
for _ in range(int(input())):
	_c = bin(int(input())).lstrip('0b')
	counter_game(_c)


t = int(input())
for _ in range(t):
	n = int(input())
	res = 0
	while n > 1:
		if '1' not in str(bin(n))[3:]:
			n >>= 1
		else:
			n -= int('1' + '0' * len(str(bin(n))[3:]), 2)
		res += 1
	if res % 2:
		print('Louise')
	else:
		print('Richard')


from math import *
nc = int(input())
for ca in range(nc):
	n = int(input())
	res = 0
	while n > 1:
		if n & n - 1 == 0:
			n >>= 1
		else:
			bit = floor(log(n) / log(2))
			n -= 1 << bit
		res ^= 1
	print(['Richard', 'Louise'][res])


import math
for _ in range(int(input())):
	N = int(input())
	lou = False
	while N != 1:
		po = 2 ** int(math.log2(N))
		if N == po:
			N >>= 1
		else:
			N -= po
		lou = not lou
	if lou:
		print('Louise')
	else:
		print('Richard')


from math import log2, pow
T = int(input())
for _ in range(T):
	n = int(input())
	m = 0
	while n > 1:
		m += 1
		c = int(log2(n))
		cc = int(pow(2, c))
		if n == cc:
			n = int(n / 2)
		else:
			n -= cc
	if m % 2:
		print('Louise')
	else:
		print('Richard')


import math
T = int(input())
for i in range(T):
	N = int(input())
	counter = 0
	while N % 2 == 0:
		counter += 1
		N = N >> 1
	while N != 1:
		if N % 2 == 1:
			counter += 1
		N = N >> 1
	if counter % 2 == 0:
		print('Richard')
	else:
		print('Louise')


for test in range(int(input())):
	N = int(input())
	c = 0
	while N > 1:
		b = bin(N)[2:]
		if b[1:].count('1'):
			N = int(b[1:], 2)
		else:
			N >>= 1
		c += 1
	print('Louise' if c % 2 else 'Richard')


import math
T = int(input())
for N in (int(input()) for i in range(T)):
	count = 0
	while N > 1:
		if N and N & N - 1 == 0:
			N >>= 1
		else:
			N -= 2 ** int(math.log(N, 2))
		count += 1
	print('Richard' if count % 2 == 0 else 'Louise')


def calculate_new_n(n):
	for i in range(64, -1, -1):
		pow_n = 1 << i
		if pow_n == n:
			n //= 2
			return n
		if pow_n < n:
			n -= pow_n
			return n
for _ in range(int(input())):
	counter = int(input())
	current_player = 0
	while 1:
		counter = calculate_new_n(counter)
		if counter == 1:
			str = 'Richard' if current_player == 1 else 'Louise'
			print(str)
			break
		else:
			current_player ^= 1


def update_n(n):
	pow_2 = 1 << n.bit_length() - 1
	if n == pow_2:
		return n // 2
	else:
		return n - pow_2

def solve(n):
	louise_turn = True
	while n > 1:
		n = update_n(n)
		louise_turn = not louise_turn
	return 'Richard' if louise_turn else 'Louise'
for _ in range(int(input())):
	n = int(input())
	print(solve(n))


def potu(n):
	return 2 ** (len(bin(n)) - 3)

def f(N, numTurns=0):
	if N == 1:
		return numTurns
	elif potu(N) == N:
		return f(int(N / 2), numTurns + 1)
	else:
		return f(int(N - potu(N)), numTurns + 1)
T = int(input())
for i in range(T):
	N = int(input())
	if f(N) % 2 == 1:
		print('Louise')
	else:
		print('Richard')


from math import *

def get_turn(turns):
	return 'Richard' if turns % 2 == 0 else 'Louise'

def npot(x):
	exp = floor(log(x, 2))
	r = int(pow(2, exp))
	return r

def run_game(n):
	turns = 0
	while n > 1:
		np = npot(n)
		if np == n:
			n >>= 1
		else:
			n -= np
		turns += 1
	print(get_turn(turns))
t = int(input())
for i in range(t):
	n = int(input())
	run_game(n)


for t in range(int(input())):
	v = bin(int(input()))
	names = ['Richard', 'Louise']
	v = list(map(int, v[2:]))
	count = 0
	while True:
		i1 = v.index(1)
		if sum(v) == 1 and i1 == len(v) - 1:
			break
		if sum(v) == 1:
			for i in range(i1, len(v)):
				v[i] = 1
		v[v.index(1)] = 0
		count += 1
	print(names[count % 2])


def is_power_of_two(num):
	bin_string = bin(num)[2:]
	if bin_string.count('1') != 1:
		return False
	return True

def largest_power_of_two_less_than(num):
	if is_power_of_two(num):
		return 2 ** (num.bit_length() - 2)
	else:
		return 2 ** (num.bit_length() - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	moves = 0
	while n != 1:
		moves += 1
		if is_power_of_two(n):
			n -= n // 2
		else:
			n -= largest_power_of_two_less_than(n)
	if moves % 2 == 0:
		print('Richard')
	else:
		print('Louise')


def toBin(n):
	temp = n
	t = ''
	top = 0
	count = 0
	index = 0
	while n > 0:
		if n & 1 == 1:
			top = index
			count = count + 1
		n >>= 1
		index = index + 1
	if count == 1:
		return temp - int(temp / 2)
	return temp - (1 << top)
amount = int(input())
for i in range(0, amount):
	n = int(input())
	c = 0
	while n != 1:
		n = toBin(n)
		c = c + 1
	if c % 2 == 0:
		print('Richard')
	else:
		print('Louise')


numTests = int(input())
for test in range(numTests):
	n = int(input())
	turns = 0
	while n & 1 == 0:
		turns += 1
		n >>= 1
	n >>= 1
	while n:
		if n & 1:
			turns += 1
		n >>= 1
	if turns % 2:
		print('Louise')
	else:
		print('Richard')


t = int(input())
for case in range(t):
	n = int(input())
	count = 1
	while n > 1:
		count += 1
		if n & n - 1 == 0:
			n >>= 1
		else:
			n -= int('1' + '0' * len(bin(n)[3:]), 2)
	if count % 2 == 0:
		print('Louise')
	else:
		print('Richard')


import math

def test_log(i):
	return_int = int(math.log(i, 2))
	if math.log(i, 2) == return_int:
		return i // 2
	else:
		return i - 2 ** return_int

def reduce(i):
	if int == 2:
		return 1
	else:
		return test_log(i)
T = int(input())
for _ in range(T):
	t = int(input())
	turn = 'Louise'
	while True:
		if t == 1:
			break
		else:
			t = reduce(t)
			if t <= 1:
				break
			elif turn == 'Louise':
				turn = 'Richard'
			else:
				turn = 'Louise'
	print(turn)


def solve(x):
	ret = False
	ii = True
	for j in bin(x)[:1:-1]:
		if j == '0':
			if ii:
				ret ^= True
		else:
			ii = False
			ret ^= True
	return ret
T = int(input())
for i in range(T):
	print('Richard' if solve(int(input())) else 'Louise')


for t in range(int(input())):
	k = 0
	n = int(input())
	d = 2 ** 63
	while n > 1:
		while d >= n:
			d //= 2
		n -= d
		k += 1
	print(['Richard', 'Louise'][k % 2])


cases = int(input())

def next(val):
	indx = 0
	while 1 < val:
		val = val >> 1
		indx += 1
	return 2 ** indx
for i in range(cases):
	n = int(input())
	louise = True
	while True:
		if n & n - 1 == 0:
			n = n >> 1
		else:
			n = n - next(n)
		if n == 1:
			print('Louise' if louise else 'Richard')
			break
		else:
			louise = False if louise else True


for t in range(int(input())):
	bits = list(bin(int(input())))[2:]
	bit_count = bits.count('1')
	right_zeros = bits[::-1].index('1')
	print('Richard' if (bit_count + right_zeros) % 2 else 'Louise')


import math
isPowerOf2 = lambda n: str(math.log2(n)).split('.')[1] == '0'

def f(N):
	count = 1
	while N != 1:
		if isPowerOf2(N):
			N //= 2
		else:
			N -= 2 ** int(math.log2(N))
		count += 1
	if count % 2 != 0:
		return 'Richard'
	else:
		return 'Louise'
for i in range(int(input())):
	print(f(int(input())))


T = int(input())
for Ti in range(T):
	N = int(input())
	result = 0
	zero = True
	while zero:
		(N, R) = divmod(N, 2)
		zero = R == 0
		if zero:
			result += 1
	while N > 0:
		(N, R) = divmod(N, 2)
		if R == 1:
			result += 1
	print('Richard' if result % 2 == 0 else 'Louise')


import math

def my_step(N):
	if math.log(N, 2).is_integer():
		return math.log(N, 2) - 1
	else:
		return math.floor(math.log(N, 2))

def winner(N):
	rich_win = True
	while N > 1:
		N -= pow(2, my_step(N))
		rich_win = not rich_win
	if rich_win:
		return 'Richard'
	else:
		return 'Louise'
T = int(input())
for i in range(0, T):
	N = int(input())
	person = winner(N)
	print(person)


for t in range(int(input())):
	turn = True
	n = int(input())
	powers_of_2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808, 18446744073709551616]
	while n != 1:
		if n in powers_of_2:
			n /= 2
			turn = not turn
		else:
			turn = not turn
			for i in range(len(powers_of_2)):
				if n <= powers_of_2[i]:
					n -= powers_of_2[i - 1]
					break
	if n == 1:
		if turn:
			print('Richard')
		else:
			print('Louise')


T = int(input())

def lsb(x):
	n = int(x)
	count = 0
	while n & 1 == 0:
		n >>= 1
		count += 1
	return count

def nbits(x):
	n = int(x)
	count = 0
	while n > 0:
		count += n & 1
		n >>= 1
	return count

def num_ops(N):
	if N == 1:
		return 1
	else:
		pass
for i in range(T):
	N = int(input())
	rounds = nbits(N) - 1 + lsb(N)
	if rounds % 2 == 0:
		print('Richard')
	else:
		print('Louise')


import math
for _ in range(int(input())):
	last_move = 1
	n = int(input())
	while n != 1:
		if n & n - 1 == 0:
			n //= 2
		else:
			n -= 2 ** math.ceil(math.log2(n)) // 2
		last_move = (last_move + 1) % 2
	if last_move == 1:
		print('Richard')
	else:
		print('Louise')


t = int(input())

def run(n):
	c = 0
	while n != 1:
		(j, base) = (0, 1)
		while base * 2 <= n:
			base *= 2
			j += 1
		if base == n:
			c += j
			break
		else:
			c += 1
			n -= base
	if c % 2 == 0:
		print('Richard')
	else:
		print('Louise')
for i in range(t):
	run(int(input()))


def turn(a):
	t = 0
	for i in range(len(a)):
		if a[i] == '1':
			t += 1
			if t == 2:
				return '0b' + a[i:]
	return a[:-1]
for i in range(int(input())):
	n = int(input())
	turns = 0
	a = bin(n)
	while a != '0b1':
		turns += 1
		a = turn(a)
	if turns % 2 == 1:
		print('Louise')
	else:
		print('Richard')


for _ in range(int(input())):
	N = bin(int(input()))
	p = 'Louise'
	while True:
		if N.count('1') == 1:
			N = N[:-1]
		else:
			i = N.index('1')
			N = N[:i] + N[i + 1:]
		if N.count('1') == 1 and N[-1] == '1':
			print(p)
			break
		p = 'Richard' if p == 'Louise' else 'Louise'


def get(n):
	x = 1
	while x * 2 < n:
		x *= 2
	return x
T = int(input())
for t in range(T):
	n = int(input())
	for i in range(1000):
		n -= get(n)
		if n == 1:
			if i % 2 == 0:
				print('Louise')
			else:
				print('Richard')
			break


T = int(input())
for t in range(T):
	N = int(input())
	N_bin = '{0:064b}'.format(N)
	zero_num = 0
	while N_bin[63 - zero_num] == '0':
		zero_num += 1
	one_num = 0
	for i in range(64):
		if N_bin[i] == '1':
			one_num += 1
	a = (one_num - 1 + zero_num) % 2
	if a:
		print('Louise')
	else:
		print('Richard')