Everything was going well in Wasseypur until Ramadhir Singh found out that Sahid Khan plans to kill him someday and takeover his mine. To protect himself, he decided to take preemptive measures and kill Sahid Khan first. However, Sahid Khan also learnt of Ramadhir Singh's plan to kill him, and soon Wasseypur was all set for bloodshed - but Chef intervened! Instead of resorting to violence, he convinced them to settle things by playing a game called the Game of Wasseypur.

The game is as follows:
There is a string S of length N consisting of only 0's and 1's. Players take turns moving - on his turn, a player chooses some block of S and erases it. The remaining parts of S are then concatenated together (without changing the order), and the other player then makes a move on this modified string.

A block in the string is defined as a maximal non-empty substring consisting of the same character. For example, if S = 0001110110011, there are 6 blocks: in order from left to right, 000, 111, 0, 11, 00, 11.

The player who is unable to make a move at the end loses the game and has to leave Wasseypur. Assuming that both players play optimally and Sahid Khan starts, find the winner of the game.

------ Input Format ------ 

- The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains a single integer N denoting the length of the string.
- The second line of each test case contains the binary string S.

------ Output Format ------ 

For each test case, output a single line containing the string “SAHID” (without quotes) if Sahid Khan will be the winner, and “RAMADHIR” otherwise.

Each character of the output can be printed either in lowercase or uppercase (so if Sahid wins, “SAHID”, “sahid” and “sAHiD” are all acceptable outputs).

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$S$ is a binary string, consisting of $0$ and $1$ only
- Sum of $N$ over all test cases will not exceed $10^{6}$

----- Sample Input 1 ------ 
2
4
0000
4
0011
----- Sample Output 1 ------ 
SAHID
RAMADHIR
----- explanation 1 ------ 
Test case 1:
There is only one block $0000$, which Sahid Khan will erase in the first move. Ramadhir Singh is then left unable to make a move and loses.

Test case 2:
There are two blocks- $00$ and $11$. Sahid has to erase any one of the two, following which Ramadhir will erase the remaining block and make the string empty. Now, Sahid cannot make a move and will lose the game.

Difficulty: MEDIUM_HARD

Solutions:
for _ in range(int(input())):
	N = int(input())
	S = input()
	c = i = 0
	while i < N:
		j = i
		while j < N and S[j] == S[i]:
			j += 1
		i = j
		c += 1
	if c % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	count = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			count += 1
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


import sys
from collections import Counter, defaultdict, deque
from math import gcd, sqrt, ceil

def li():
	return [int(i) for i in sys.stdin.readline().split()]

def si():
	return sys.stdin.readline().split()

def ii():
	return int(sys.stdin.readline())

def ip():
	return input()
for tastcas in range(int(input())):
	n = ii()
	a = ip()
	c = 1
	f = 1
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			c += 1
	if c % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
while t:
	n = int(input())
	s = str(input())
	c = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			c += 1
	if c % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')
	t -= 1


t = int(input())
while t:
	n = int(input())
	a = input()
	sum = 1
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			sum = sum + 1
	d = sum
	if d % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	m = list(map(str, input()))
	count = 0
	counter = 0
	arrow = '-1'
	while counter < n:
		if m[counter] == '1' and arrow != '1':
			count += 1
			arrow = '1'
		elif m[counter] == '0' and arrow != '0':
			count += 1
			arrow = '0'
		counter += 1
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	length = int(input())
	s = input()
	blocks = 1
	for i in range(length - 1):
		if s[i] != s[i + 1]:
			blocks += 1
	print('RAMADHIR') if blocks % 3 == 2 else print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	res = ''
	res += s[0]
	for i in range(1, len(s)):
		if s[i] != res[-1]:
			res += s[i]
	if len(res) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


def solve(c):
	if c % 3 == 2:
		return 'RAMADHIR'
	return 'SAHID'
for _ in range(int(input())):
	n = int(input())
	a = input()
	c = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			c += 1
	print(solve(c))


for _ in range(int(input())):
	n = int(input())
	arr = input()
	j = 0
	c = 1
	for i in range(1, n):
		if arr[i] != arr[j]:
			c += 1
			j = i
	if c % 3 < 2:
		print('SAHID')
	else:
		print('RAMADHIR')


import sys
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	c = 1
	t = s[0]
	for i in range(n):
		if s[i] != t:
			t = s[i]
			c += 1
	if c == 1:
		print('SAHID')
	elif c == 2:
		print('RAMADHIR')
	elif c % 3 == 0 or c % 3 == 1:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input())
dp = [-1] * 100001
dp[1] = 0
dp[2] = 1
dp[3] = 0
dp[4] = 0
for i in range(5, 100001):
	if dp[i - 1] == 0:
		pos1 = 1
	else:
		pos1 = 0
	if dp[i - 2] == 0:
		pos2 = 1
	else:
		pos2 = 0
	if pos1 == 0 or pos2 == 0:
		dp[i] = 0
	else:
		dp[i] = 1
while t > 0:
	t -= 1
	n = int(input())
	l = str(input())
	blocks = 0
	i = 0
	while i < n:
		j = i
		blocks += 1
		while j < n and l[j] == l[i]:
			j += 1
		i = j
	if dp[blocks] == 0:
		print('SAHID')
	else:
		print('RAMADHIR')


for _ in range(int(input())):
	(c, d, ctr) = (int(input()), input(), 1)
	for i in range(c - 1):
		ctr += d[i] != d[i + 1]
	print('SAHID' if ctr % 3 - 2 else 'RAMADHIR')


import math
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = s[0]
	c = 1
	for i in range(n):
		if s[i] != t:
			t = s[i]
			c += 1
	if c == 1:
		print('SAHID')
	elif c == 2:
		print('RAMADHIR')
	elif c % 3 == 0:
		print('SAHID')
	elif c % 3 == 1:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input())

def solution(s):
	groups = 0
	crt = None
	for c in s:
		if c != crt:
			groups += 1
			crt = c
	return 'SAHID' if groups % 3 != 2 else 'RAMADHIR'
for _ in range(t):
	n = int(input())
	s = input().strip()
	print(solution(s))


for i in range(int(input())):
	n = int(input())
	s = input()
	ans = 0
	i = 0
	c = []
	while i < n:
		j = i
		while j + 1 < n and s[j] == s[j + 1]:
			j += 1
		c.append(j - i + 1)
		j += 1
		i = j
		ans += 1
	if ans == 2 or (ans > 2 and ans % 3 == 2):
		print('RAMADHIR')
	else:
		print('SAHID')


from itertools import permutations as per
from math import factorial as fact
from difflib import SequenceMatcher
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	c = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			c += 1
	if c == 1:
		print('SAHID')
	elif c == 2:
		print('RAMADHIR')
	elif (c - 2) % 3 == 0:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	change = s.count('01') + s.count('10') + 1
	if change % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	sum = 0
	for k in range(n - 1):
		if s[k] == s[k + 1]:
			pass
		else:
			sum += 1
	if (sum + 1) % 3 != 2:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	blocks = 1
	temp = s[0]
	for i in range(1, n):
		if s[i] != temp:
			temp = s[i]
			blocks += 1
	if blocks == 1:
		print('SAHID')
	elif blocks == 2:
		print('RAMADHIR')
	elif blocks % 3 == 0:
		print('SAHID')
	elif blocks % 3 == 1:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input())
for i in range(t):
	l = int(input())
	s = input()
	count = 1
	for i in range(1, l):
		if s[i] != s[i - 1]:
			count = count + 1
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


from collections import defaultdict
for _ in range(int(input())):
	(_, s, c) = (input(), input(), 1)
	for (x, y) in zip(s, s[1:]):
		c += x != y
	d = defaultdict()
	(d[1], d[2]) = (1, 0)
	for x in range(3, c + 1):
		d[x] = d[x - 1] ^ d[x - 2]
	print('SAHID' if d[c] else 'RAMADHIR')


for _ in range(int(input())):
	(_, s, c) = (input(), input(), 1)
	for (x, y) in zip(s, s[1:]):
		c += x != y
	print('SAHID' if (c + 1) % 3 else 'RAMADHIR')


t = int(input())
while t > 0:
	x = 1
	t = t - 1
	rt = int(input())
	j = input()
	l = str(j)
	for i in range(len(l) - 1):
		if l[i] != l[i + 1]:
			x = x + 1
	if x % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


def func(N, S):
	return 'RAMADHIR' if 1 + len([i for i in range(N - 1) if S[i] != S[i + 1]]) % 3 == 2 else 'SAHID'
for i in range(int(input())):
	print(func(int(input()), input()))


def func(S, N):
	c = 1
	for i in range(0, N - 1):
		if S[i] != S[i + 1]:
			c += 1
	if c % 3 == 2:
		return 'RAMADHIR'
	return 'SAHID'
T = int(input())
for i in range(T):
	N = int(input())
	S = input()
	print(func(S, N))


cache = dict()

def dp(no, move='S'):
	other = 'R' if move == 'S' else 'S'
	if (no, move) in cache:
		return cache[no, move]
	if no == 1:
		return move
	elif no == 2:
		return other
	else:
		a = dp(no - 1, other) == move or dp(no - 2, other) == move
	ret = move if a else other
	cache[no, move] = ret
	return ret

def get_blocks(s):
	blocks = 0
	n = len(s)
	i = 0
	while i < n:
		cur = s[i]
		while i < n and cur == s[i]:
			i += 1
		blocks += 1
	return blocks
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	blocks = get_blocks(s)
	ans = 'SAHID' if blocks % 3 != 2 else 'RAMADHIR'
	print(ans)


for T in range(int(input())):
	N = int(input())
	S = input()
	cnt = 1
	i = 1
	while i < N:
		if S[i] != S[i - 1]:
			cnt += 1
		i += 1
	print('RAMADHIR' if cnt % 3 == 2 else 'SAHID')


for _ in range(int(input())):
	n = int(input())
	prev = None
	s = input()
	ans = ''
	for el in s:
		if prev == None:
			ans += el
			prev = el
		elif prev != el:
			ans += el
			prev = el
		else:
			continue
	print('SAHID' if (len(ans) - 2) % 3 != 0 else 'RAMADHIR')


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	start = s[0]
	count = 1
	for i in range(1, n):
		if s[i] != start:
			count += 1
			start = s[i]
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = input()
	ans = 1
	for j in range(n - 1):
		if s[j] != s[j + 1]:
			ans += 1
	if ans == 1:
		print('SAHID')
	else:
		ans = ans - 2
		if ans % 3 == 0:
			print('RAMADHIR')
		else:
			print('SAHID')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s1 = 1
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			s1 += 1
	if s1 % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


from sys import stdin

def winner(S):
	r = S[0]
	blk = 1
	for c in S:
		if c != r:
			blk += 1
			r = c
	return 'RAMADHIR' if 2 == blk % 3 else 'SAHID'
inp = stdin.readline
T = int(inp())
for tx in range(T):
	N = inp()
	print(winner(inp().strip()))


import sys, os, io
input = sys.stdin.readline
PI = 3.141592653589793
INF = float('inf')
MOD = 1000000007

def bin32(num):
	return '{0:032b}'.format(num)

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
dp = [-1, 1, 2]
for i in range(3, 10 ** 5 + 1):
	if dp[i - 1] == 2 or dp[i - 2] == 2:
		dp.append(1)
	else:
		dp.append(2)
for t in range(ii()):
	t += 1
	n = ii()
	s = input().strip()
	ans = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			ans += 1
	store = [-1, 'SAHID', 'RAMADHIR']
	print(store[dp[ans]])


for i in range(int(input())):
	n = int(input())
	s = input()
	t = 0
	k = 2
	for j in range(n):
		if s[j] == '1' and k != 1:
			k = 1
			t += 1
		if s[j] == '0' and k != 0:
			k = 0
			t += 1
	if t % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	seg = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			seg += 1
	dp = [False for _ in range(seg + 1)]
	dp[1] = True
	for i in range(3, seg + 1):
		dp[i] = not dp[i - 1] & dp[i - 2]
	if dp[seg] == 1:
		print('SAHID')
	else:
		print('RAMADHIR')


def solve(s, n):
	player1 = 'SAHID'
	player2 = 'RAMADHIR'
	if n == 0:
		return player1
	k = 1
	flag = s[0]
	for i in s[1:]:
		if i != flag:
			flag = i
			k += 1
	return player2 if k % 3 == 2 else player1
for _ in range(int(input())):
	n = int(input())
	s = input()
	ans = solve(s, n)
	print(ans)


n = int(input())
for i in range(n):
	b = int(input())
	a = list(input())
	count = 1
	for i in range(len(a)):
		if i + 1 < len(a) and a[i] != a[i + 1]:
			count += 1
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


T = int(input())
for i in range(T):
	N = int(input())
	S = list(input())
	blocks = 1
	for j in range(len(S) - 1):
		if S[j] != S[j + 1]:
			blocks += 1
	if blocks in [1, 3, 4]:
		print('SAHID')
	elif blocks in [2, 5]:
		print('RAMADHIR')
	elif (blocks - 5) % 3 == 0:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
for q in range(t):
	n = int(input())
	s = input()
	i = 0
	j = 1
	c = 1
	while i < j and j < n:
		if s[i] != s[j]:
			c += 1
		i += 1
		j += 1
	if c % 3 != 2:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input(''))
lst = []
for i in range(t):
	c = 0
	f = int(input(''))
	n = input('')
	for j in range(len(n) - 1):
		if n[j] == n[j + 1]:
			pass
		else:
			c = c + 1
	if (c + 1) % 3 != 2:
		lst.append('SAHID')
	else:
		lst.append('RAMADHIR')
for i in lst:
	print(i)


for _ in range(int(input())):
	N = int(input())
	A = input()
	s = A[0]
	k = 1
	for i in range(1, N):
		if A[i] != s:
			k += 1
			s = A[i]
	if (k + 1) % 3 == 0:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	p = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			p += 1
	if p % 3 == 0 or p % 3 == 1:
		print('SAHID')
	else:
		print('RAMADHIR')


mod = 1000000007
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip('\n')
	c = 1
	for i in range(1, n):
		if s[i - 1] != s[i]:
			c += 1
	if c % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


mod = 1000000007
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip('\n')
	li = [s[0]]
	for i in range(1, n):
		if li[-1] != s[i]:
			li.append(s[i])
	if len(li) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
sa = 'SAHID'
ra = 'RAMADHIR'
for i in range(t):
	total = 1
	l = input()
	s = input()
	lock = int(s[0])
	for j in s:
		if j == '0' and lock == 1:
			total += 1
			lock = 0
		elif j == '0' and lock == 0:
			pass
		elif j == '1' and lock == 0:
			total += 1
			lock = 1
		elif j == '1' and lock == 1:
			pass
	if total % 3 != 2:
		print(sa)
	else:
		print(ra)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	zb = 0
	ob = 0
	p = s[0]
	if s[0] == '0':
		zb += 1
	else:
		ob += 1
	for i in range(len(s)):
		if s[i] != p:
			if s[i] == '0':
				zb += 1
			else:
				ob += 1
			p = s[i]
	tb = zb + ob
	if tb % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	turn = 1
	first = s[0]
	for i in range(1, n):
		if s[i] != first:
			first = s[i]
			turn += 1
	if turn == 1:
		print('SAHID')
	elif turn == 2:
		print('RAMADHIR')
	elif turn % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
for test in range(t):
	n = int(input())
	s = input()
	ctr = 1
	a = s[0]
	for i in s:
		if a == i:
			continue
		else:
			ctr += 1
			a = i
	if ctr % 3 != 2:
		print('SAHID')
	else:
		print('RAMADHIR')


t = int(input())
x = 0
c = 0
while t > 0:
	n = int(input())
	s = input()
	x = list(s)
	for i in range(len(x) - 1):
		if x[i] != x[i + 1]:
			c += 1
	if (c + 1) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')
	c = 0
	t -= 1


def noofblocks(s, n):
	c = 1
	x = s[0]
	for i in range(1, n):
		if s[i] != x:
			c += 1
			x = s[i]
	return c
for _ in range(int(input())):
	n = int(input())
	s = input()
	b = noofblocks(s, n)
	if b % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


from itertools import groupby
t = int(input())
for i in range(t):
	n = int(input())
	block = input()
	ls = [''.join(group) for (ele, group) in groupby(block)]
	if len(ls) in range(2, 2 * n, 3):
		print('RAMADHIR')
		continue
	else:
		print('SAHID')
		continue


for k in range(int(input())):
	length = int(input())
	s = input()
	l = len(s)
	count = 0
	for i in range(l):
		if i == l - 1:
			continue
		elif s[i] != s[i + 1]:
			count += 1
	if (count + 1) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


s = 'SAHID'
r = 'RAMADHIR'
for _ in range(int(input())):
	n = int(input())
	st = input()
	a = []
	t = st[0]
	x = st[0]
	for j in range(1, n):
		i = st[j]
		if t != i:
			a.append(x)
			x = i
			t = i
		else:
			x = x + i
		if j == n - 1:
			a.append(x)
	if len(a) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


import numpy as np
t = int(input())
for __ in range(t):
	n = int(input())
	s = np.array([int(val) for val in input()])
	s = np.where(np.diff(s))[0]
	res = s.size + 1
	if res % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
for i in range(t):
	a = int(input())
	s = input()
	c = 1
	for j in range(1, len(s)):
		if s[j - 1] != s[j]:
			c += 1
	k = (c - 2) / 3
	if c == 1:
		print('SAHID')
	elif c == 2:
		print('RAMADHIR')
	elif k % 1 == 0:
		print('RAMADHIR')
	else:
		print('SAHID')


for i in range(int(input())):
	N = int(input())
	string = input()
	count = 1
	for i in range(1, len(string)):
		if string[i - 1] != string[i]:
			count += 1
	if count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


for _ in range(int(input())):
	n = int(input())
	s = input()
	c = 1
	a = s[0]
	for i in s:
		if i != a:
			c += 1
			a = i
	if c % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
for i in range(t):
	n = input()
	s = input() + 'x'
	a = s[0]
	y = ''
	lst = []
	for i in range(len(s)):
		if s[i] == a:
			y += s[i]
		else:
			a = s[i]
			lst.append(y)
			y = a
	if len(lst) % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')


t = int(input())
while t > 0:
	n = int(input())
	ip = input()
	arr = []
	for ch in ip:
		if arr == []:
			arr.append(ch)
		elif arr[-1] != ch:
			arr.append(ch)
	i = 0
	while arr:
		if len(arr) % 3 != 0:
			m = len(arr) // 2
			if m < len(arr) - 1:
				arr.pop(m)
				arr.pop(m)
			else:
				arr.pop(m)
		else:
			arr.pop(0)
		i += 1
	print('SAHID' if i % 2 == 1 else 'RAMADHIR')
	t -= 1


T = int(input())
for i in range(T):
	N = int(input())
	S = input()
	count = 1
	for i in range(len(S) - 1):
		if S[i] != S[i + 1]:
			count += 1
	if (count + 1) % 3 != 0:
		print('SAHID')
	else:
		print('RAMADHIR')


try:
	T = int(input())
	h = []
	for i in range(T):
		n = int(input())
		s = input()
		sum = 0
		for k in range(n - 1):
			if s[k] == s[k + 1]:
				pass
			else:
				sum += 1
		if (sum + 1) % 3 != 2:
			h.append('SAHID')
		else:
			h.append('RAMADHIR')
	for w in h:
		print(w)
except:
	pass


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s = list(s)
	count = 1
	for i in range(1, n):
		if s[i - 1] != s[i]:
			count += 1
	if count == 1:
		print('SAHID')
	elif count == 2:
		print('RAMADHIR')
	elif count % 3 == 2:
		print('RAMADHIR')
	else:
		print('SAHID')