Nitin and Sobhagya were playing a game with coins. If Sobhagya has more coins then he is *winning*, otherwise Nitin is winning. Note that this means if both Nitin and Sobhagya have the same number of coins, then Nitin is winning.

Initially Nitin has A coins while Sobhagya has B coins. Then Ritik came and gave his C coins to the player who is not winning currently, after which Satyarth came and repeated the same process (gave his D coins to the player who is not winning currently).

Find the final winner of the game.

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

- The first line of the input contains an integer T - the number of test cases. The test cases then follow.
- The only line of each test case contains four space-separated integers A, B, C, and D.

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

For each test case, output on a single line N if Nitin is the final winner of the game, or S if Sobhagya is the final winner of the game.

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

$1 ≤ T ≤ 1000$
$0 ≤ A, B, C, D ≤ 10^{6}$

----- Sample Input 1 ------ 
3
2 3 4 5
3 3 3 3
2 3 1 2

----- Sample Output 1 ------ 
S
N
S

----- explanation 1 ------ 
- Test case $1$:
- Initially, Nitin has $2$ coins and Sobhagya has $3$ coins, so Sobhagya is winning.
- Then, Ritik gives his $4$ coins to Nitin. Now Nitin has $6$ coins and Sobhagya has $3$ coins, so Nitin is winning.
- Then, Satyarth gives his $5$ coins to Sobhagya. Finally Nitin has $6$ coins and Sobhagya has $8$ coins, so Sobhagya is the final winner.
- Test case $2$:
- Initially, Nitin has $3$ coins and Sobhagya has $3$ coins, so Nitin is winning.
- Then, Ritik gives his $3$ coins to Sobhagya. Now Nitin has $3$ coins and Sobhagya has $6$ coins, so Sobhagya is winning.
- Then, Satyarth gives his $3$ coins to Nitin. Finally Nitin has $6$ coins and Sobhagya has $6$ coins, so Nitin is the final winner.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a >= b:
		a = a
		b = b + c
	else:
		b = b
		a = a + c
	if a >= b:
		a = a
		b = b + d
	else:
		b = b
		a = a + d
	if a >= b:
		print('N')
	else:
		print('S')


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(2, 4):
		if x[0] > x[1] or x[0] == x[1]:
			x[1] = x[1] + x[j]
		else:
			x[0] = x[0] + x[j]
	if x[0] > x[1] or x[0] == x[1]:
		print('N')
	else:
		print('S')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a < b:
		a += c
	else:
		b += c
	if a < b:
		a += d
	else:
		b += d
	print('S' if b > a else 'N')


for i in range(int(input())):
	(m, n, o, p) = map(int, input().split())
	for i in range(2):
		if m >= n:
			n += o
			o = p
		else:
			m += o
			o = p
	if m >= n:
		print('N')
	else:
		print('S')


for i in range(int(input())):
	(N, S, R, Sat) = map(int, input().split())
	if N >= S:
		S += R
	else:
		N += R
	if N >= S:
		S += Sat
	else:
		N += Sat
	if N >= S:
		print('N')
	else:
		print('S')


for _ in range(int(input())):
	(n, s, c, d) = map(int, input().split())
	for i in range(2):
		if n > s or n == s:
			s += c
			c = d
		else:
			n += c
			c = d
	if n < s:
		print('S')
	else:
		print('N')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, d) = map(int, input().split())
	if b > a:
		a = a + c
	else:
		b = b + c
	if b > a:
		a = a + d
	else:
		b = b + d
	if b > a:
		print('S')
	else:
		print('N')


t = int(input())
while t:
	(n, s, r, satya) = map(int, input().split())
	if n >= s:
		s += r
	else:
		n += r
	if n >= s:
		s += satya
	else:
		n += satya
	print('N') if n >= s else print('S')
	t -= 1


T = int(input())
for i in range(T):
	(A, B, C, D) = map(int, input().split())
	if A >= B:
		B += C
	else:
		A += C
	if A >= B:
		B += D
	else:
		A += D
	if A >= B:
		print('N')
	else:
		print('S')


for _ in range(int(input())):
	(A, B, C, D) = map(int, input().split())
	if A >= B:
		B += C
	else:
		A += C
	if A >= B:
		B += D
	else:
		A += D
	if A >= B:
		print('N')
	else:
		print('S')


t = int(input())
while t > 0:
	(a1, b1, c1, d1) = input().split()
	a = int(a1)
	b = int(b1)
	c = int(c1)
	d = int(d1)
	if a < b:
		a = a + c
	else:
		b = b + c
	if a < b:
		a = a + d
	else:
		b = b + d
	if b > a:
		print('S')
	else:
		print('N')
	t = t - 1


def f(a, b, c, d):
	player1 = a
	player2 = b
	for i in [c, d]:
		if player1 >= player2:
			player2 += i
		else:
			player1 += i
	return player1 >= player2
for i in range(int(input())):
	(a, b, c, d) = input().split()
	(a, b, c, d) = (int(a), int(b), int(c), int(d))
	if f(a, b, c, d):
		print('N')
	else:
		print('S')


for _ in range(int(input())):
	(n, s, r, st) = map(int, input().split())
	if n < s:
		n = n + r
	else:
		s = s + r
	if n < s:
		n = n + st
	else:
		s = s + st
	if n >= s:
		print('N')
	else:
		print('S')


for inputs in range(int(input())):
	l = list(map(int, input().split()))
	if l[0] < l[1]:
		l[0] += l[2]
	else:
		l[1] += l[2]
	if l[0] < l[1]:
		l[0] += l[3]
	else:
		l[1] += l[3]
	if l[0] < l[1]:
		print('S')
	else:
		print('N')


Test = int(input())
for Cases in range(Test):
	(Nitin, Sobhagya, Ritik, Satyarth) = map(int, input().split())
	if Nitin >= Sobhagya:
		Sobhagya += Ritik
	else:
		Nitin += Ritik
	if Nitin >= Sobhagya:
		Sobhagya += Satyarth
	else:
		Nitin += Satyarth
	if Nitin >= Sobhagya:
		print('N')
	else:
		print('S')


t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		(a1, b1, c1, d1) = input().split()
		a = int(a1)
		b = int(b1)
		c = int(c1)
		d = int(d1)
		if 0 <= a <= 1000000 and 0 <= b <= 1000000 and (0 <= c <= 1000000) and (0 <= d <= 1000000):
			if a == b:
				b += c
				if a < b:
					a += d
			else:
				if a < b:
					a += c
				elif b < a:
					b += c
				if a == b:
					b += d
				elif a < b:
					a += d
				elif b < a:
					b += d
		if a == b:
			print('N')
		elif a > b:
			print('N')
		else:
			print('S')


t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		(a, b, c, d) = input().split(' ')
		(a, b, c, d) = (int(a), int(b), int(c), int(d))
		if a > b or a == b:
			win = a
			b += c
		else:
			win = b
			a += c
		if a > b or a == b:
			win = a
			b += d
		else:
			win = b
			a += d
		if a > b or a == b:
			print('N')
		else:
			print('S')


t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		(a1, b1, c1, d1) = input().split(' ')
		a = int(a1)
		b = int(b1)
		c = int(c1)
		d = int(d1)
		if 1 <= a <= 10 ** 6 and 1 <= b <= 10 ** 6 and (1 <= c <= 10 ** 6) and (1 <= d <= 10 ** 6):
			if a > b:
				b = b + c
			elif a < b:
				a = a + c
			elif a == b:
				b = b + c
			if a > b:
				b = b + d
			elif a < b:
				a = a + d
			elif a == b:
				b = b + d
			if a > b:
				print('N')
			elif a < b:
				print('S')
			elif a == b:
				print('N')


T = int(input())
if 1 <= T <= 1000:
	for i in range(T):
		(A1, B1, C1, D1) = input().split(' ')
		A = int(A1)
		B = int(B1)
		C = int(C1)
		D = int(D1)
		if 1 <= A <= 10 ** 6 and 1 <= B <= 10 ** 6 and (1 <= C <= 10 ** 6) and (1 <= D <= 10 ** 6):
			if A == B:
				print('N')
			elif A < B:
				A += C
				if A < B:
					A += D
				else:
					B += D
			else:
				B += C
				if B < A:
					B += D
				else:
					A += D
			if A > B:
				print('N')
			elif B > A:
				print('S')


for i in range(int(input())):
	coins = input().split(' ')
	coins = [int(c) for c in coins]
	for c in range(2, 4):
		if coins[0] < coins[1]:
			coins[0] += coins[c]
		else:
			coins[1] += coins[c]
	print('N' if coins[0] >= coins[1] else 'S')


t = int(input())
for _ in range(t):
	(x, y, z, a) = map(int, input().split())
	if x < y:
		x = x + z
	else:
		y += z
	if x < y:
		x = x + a
	else:
		y += a
	if x < y:
		print('S')
	else:
		print('N')


for i in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	if x < y:
		x = x + a
	else:
		y = y + a
	if x < y:
		x = x + b
	else:
		y = y + b
	if x >= y:
		print('N')
	elif y > x:
		print('S')


n = int(input())
for i in range(n):
	(N, S, Ri, Sa) = list(map(int, input().split()))
	if N >= S:
		S = S + Ri
	else:
		N = N + Ri
	if N >= S:
		S = S + Sa
	else:
		N = N + Sa
	if N >= S:
		print('N')
	else:
		print('S')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	for i in range(2):
		x = min(a, b)
		if a < b and i == 0:
			a = x + c
		elif b <= a and i == 0:
			b = x + c
		elif a < b and i == 1:
			a = x + d
		elif b <= a and i == 1:
			b = x + d
	if a < b:
		print('S')
	else:
		print('N')


t = int(input())
for t in range(t):
	lis = list(map(int, input().split()))
	(n, s, r, s1) = lis
	if s > n:
		n = n + r
		if s > n:
			n = n + s1
		else:
			s = s + s1
		if s > n:
			print('S')
		else:
			print('N')
	else:
		s = s + r
		if s > n:
			n = n + s1
		else:
			s = s + s1
		if s > n:
			print('S')
		else:
			print('N')


for i in range(int(input())):
	(n, s, a, b) = map(int, input().split())
	if n > s or n == s:
		s = s + a
	else:
		n = n + a
	if n > s or n == s:
		s = s + b
	else:
		n = n + b
	if n > s or n == s:
		print('N')
	else:
		print('S')


def game_friends(a, b, c, d):
	if a >= b:
		b += c
		if a >= b:
			b += d
		else:
			a += d
	else:
		a += c
		if a >= b:
			b += d
		else:
			a += d
	if a >= b:
		return 'N'
	else:
		return 'S'
T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	print(game_friends(a, b, c, d))