Read problems statements in Mandarin Chinese  , Russian and Vietnamese 

Chef likes to play table tennis. He found some statistics of matches which described who won the points in order. A game shall be won by the player first scoring 11 points except in the case when both players have 10 points each, then the game shall be won by the first player subsequently gaining a lead of 2 points. Could you please help the Chef find out who the winner was from the given statistics? (It is guaranteed that statistics represent  always a valid, finished match.) 

------ Input ------ 

The first line of the input contains an integer T, denoting the number of test cases. The description of T test cases follows. Each test case consist a binary string S, which describes a match. '0' means Chef lose a point, whereas '1' means he won the point.

------ Output ------ 

For each test case, output on a separate line a string describing who won the match. If Chef won then print "WIN" (without quotes), otherwise print "LOSE" (without quotes).

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

1 ≤ T ≤ 1000
1 ≤ length(S) ≤ 100

----- Sample Input 1 ------ 
2
0101111111111
11100000000000

----- Sample Output 1 ------ 
WIN
LOSE
----- explanation 1 ------ 
Example case 1. Chef won the match 11:2, his opponent won just two points, the first and the third of the match.
Example case 2. Chef lost this match 11:3, however he started very well the match, he won the first three points in a row, but maybe he got tired and after that lost 11 points in a row.

Source: codechef | Difficulty: EASY
Tags: String algorithms

Constructive algorithms

Data structures

Ad-hoc


Solutions:
for _ in range(int(input())):
	n = input()
	c1 = 0
	c0 = 0
	for i in range(len(n)):
		if n[i] == '1':
			c1 += 1
		else:
			c0 += 1
	if c1 >= c0:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	r = input()
	if r.count('1') >= r.count('0'):
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for x in range(t):
	s = input()
	w = 0
	l = 0
	for i in s:
		if i == '1':
			w += 1
		elif i == '0':
			l += 1
	if w > l:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	x = input()
	if x.count('1') >= x.count('0'):
		print('WIN')
	else:
		print('LOSE')


def check_winner(s):
	chef_score = 0
	opponent_score = 0
	for i in range(len(s)):
		if s[i] == '1':
			chef_score += 1
		else:
			opponent_score += 1
		if chef_score >= 11 and chef_score - opponent_score >= 2:
			return 'WIN'
		elif opponent_score >= 11 and opponent_score - chef_score >= 2:
			return 'LOSE'
	return 'DRAW'

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		print(check_winner(s))
main()


n = int(input())
for i in range(n):
	x = input()
	o = 0
	d = 0
	for i in x:
		if i == '0':
			o += 1
		else:
			d += 1
	if d > o:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for _ in range(t):
	score = 0
	binary_str = input()
	for char in binary_str:
		if char == '0':
			score -= 1
		else:
			score += 1
	if score > 0:
		print('WIN')
	else:
		print('LOSE')


n = eval(input())
for i in range(n):
	a = str(input())
	c = 0
	d = 0
	for j in a:
		if j == '1':
			c = c + 1
		else:
			d = d + 1
	if c > d:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for i in range(t):
	s = input()
	if s.count('1') > s.count('0'):
		print('WIN')
	else:
		print('LOSE')


for t in range(int(input())):
	s = input()
	one = s.count('1')
	zero = s.count('0')
	print('WIN' if one > zero else 'LOSE')


t = int(input())
for i in range(0, t):
	s = input()
	c = c1 = 0
	for j in s:
		if j == '1':
			c = c + 1
		else:
			c1 = c1 + 1
	if c > c1:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for i in range(t):
	s = input()
	for i in range(len(s)):
		loss = s.count('0')
		win = s.count('1')
	if win > loss:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	s = input()
	w = s.count('1')
	l = s.count('0')
	if w > l:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	S = input().strip()
	c1 = S.count('1')
	c2 = S.count('0')
	if c1 > c2:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	s = input()
	o = []
	z = []
	for i in s:
		if i == '1':
			o.append(i)
		else:
			z.append(i)
	if len(o) >= len(z):
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for _ in range(t):
	s = input()
	w = []
	l = []
	for i in s:
		if i == '0':
			l.append(i)
		else:
			w.append(i)
	if len(l) > len(w):
		print('LOSE')
	else:
		print('WIN')


for t in range(int(input())):
	score = input()
	score_1 = [one for one in score if one == '1']
	score_0 = [zero for zero in score if zero == '0']
	if len(score_1) > len(score_0):
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for i in range(t):
	score = input()
	chef = 0
	opp = 0
	for j in range(len(score)):
		if score[j] == '1':
			chef = chef + 1
		else:
			opp = opp + 1
	if chef > opp:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for i in range(t):
	s = input()
	x = 0
	for i in s:
		if i == '1':
			x = x + 1
	if x > len(s) // 2:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	a = input()
	c = 0
	d = 0
	for i in a:
		if i == '1':
			c += 1
		else:
			d += 1
	if c > d:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	l = list(map(int, input()))
	if sum(l) > len(l) // 2:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	n = input()
	l = len(n)
	c = 0
	for j in n:
		if j == '1':
			c += 1
	if c > l // 2:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	a = 0
	b = 0
	for j in range(n):
		if s[j] == '1':
			a += 1
		if s[j] == '0':
			b += 1
		if a == 11 and b <= 9:
			print('WIN')
			break
		if b == 11 and a <= 9:
			print('LOSE')
		if a > 11 and a - b > 1:
			print('WIN')
			break
		if b > 11 and b - a > 1:
			print('LOSE')
			break


T = int(input())
while T > 0:
	S = input()
	countC = 0
	countP = 0
	for i in range(len(S)):
		if S[i] == '1':
			countC += 1
		else:
			countP += 1
	if countC > countP:
		print('WIN')
	else:
		print('LOSE')
	T = T - 1


for i in range(int(input())):
	count = 0
	cnt = 0
	s = input()
	for i in range(len(s)):
		if s[i] == '0':
			count += 1
		else:
			cnt += 1
	if count > cnt:
		print('LOSE')
	else:
		print('WIN')


t = int(input())
while t != 0:
	s = input()
	ones = s.count('1')
	zero = s.count('0')
	if ones > zero:
		print('WIN')
	else:
		print('LOSE')
	t -= 1


for i in range(int(input())):
	s = input()
	ones = s.count('1')
	zero = s.count('0')
	if ones > zero:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	s = input()
	a = s.count('1')
	b = s.count('0')
	if a > b:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	n = input()
	o = n.count('1')
	z = n.count('0')
	if o > z:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for _ in range(t):
	s = input()
	c1 = s.count('1')
	c2 = s.count('0')
	if c1 == c2 == 10:
		c1 = c1 + 2
	if c1 >= 11 and c2 < c1:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
i = 0
for i in range(i, t):
	a = input()
	count = count1 = 0
	for j in a:
		if j == '1':
			count = count + 1
		else:
			count1 = count1 + 1
	if count > count1:
		print('WIN')
	else:
		print('LOSE')


for t in range(int(input())):
	a = input()
	l = a.count('1')
	m = a.count('0')
	if l > m:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	list1 = list(input())
	arr1 = [int(x) for x in list1]
	zeros = 0
	ones = 0
	for y in arr1:
		if y == 0:
			zeros += 1
		if y == 1:
			ones += 1
	if ones > zeros:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	a = input()
	b = a.count('1')
	c = a.count('0')
	if b - 2 >= c:
		print('WIN')
	else:
		print('LOSE')


for t in range(int(input())):
	x = input()
	a = 0
	b = 0
	for t in x:
		if t == '1':
			a += 1
		else:
			b += 1
	if a > b:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	string = list(input())
	count = 0
	count1 = 0
	for i in string:
		if i == '1':
			count = count + 1
		else:
			count1 = count1 + 1
	if count > count1:
		print('WIN')
	else:
		print('LOSE')


T = int(input())
for i in range(T):
	s = input()
	k = [n for n in s]
	j = k.count('1')
	g = k.count('0')
	if j > g:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
while t > 0:
	s = input()
	size = len(s)
	a = b = 0
	for i in range(size):
		if s[i] == '1':
			a = a + 1
		else:
			b = b + 1
	if a > b:
		print('WIN')
	else:
		print('LOSE')
	t = t - 1


for i in range(int(input())):
	s = input()
	c = 0
	b = 0
	for i in s:
		if i == '0':
			c += 1
		else:
			b += 1
	if c > b:
		print('LOSE')
	else:
		print('WIN')


for i in range(int(input())):
	a = input()
	cz = 0
	co = 0
	for i in a:
		if i == '0':
			cz = cz + 1
		else:
			co = co + 1
	if cz > co:
		print('LOSE')
	else:
		print('WIN')


t = int(input())
for i in range(t):
	s = input()
	count1 = 0
	for j in s:
		if j == '1':
			count1 = count1 + 1
	count0 = len(s) - count1
	if count1 > count0:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	x = input()
	b = 0
	c = 0
	n = 0
	for i in x:
		if i == '1':
			c = c + 1
		if i == '0':
			b = b + 1
	if n == 0:
		if c > b:
			print('WIN')
		else:
			print('LOSE')


a = int(input())
while a != 0:
	s = input('')
	(c1, c2) = (0, 0)
	for i in range(0, len(s)):
		if s[i] == '1':
			c1 = c1 + 1
		else:
			c2 = c2 + 1
	if c1 > c2:
		print('WIN')
	else:
		print('LOSE')
	a = a - 1


for t in range(int(input())):
	score = input()
	if score.count('1') > score.count('0'):
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	k = input()
	s = k.count('1')
	z = k.count('0')
	if s >= z:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	s = str(input())
	x = s.count('1')
	y = s.count('0')
	if x > y:
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	s = input()
	d = s.count('1')
	m = s.count('0')
	if d > m:
		print('WIN')
	else:
		print('LOSE')


t = int(input())
for _ in range(t):
	s = input()
	chef = s.count('1')
	opponent = s.count('0')
	print('WIN' if chef > opponent else 'LOSE')


for i in range(int(input())):
	n = input()
	m = 0
	o = 0
	for j in n:
		if j == '1':
			m = m + 1
		else:
			o = o + 1
	if m >= o:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	s = input()
	w = 0
	l = 0
	if len(s) < 20:
		w = s.count('1')
		l = len(s) - w
		if w > l:
			print('WIN')
		else:
			print('LOSE')
	else:
		for i in range(len(s)):
			if w == 10 and l == 10:
				if s[i] == '1' and s[i + 1] == '1':
					w = w + 1
					break
				elif s[i] == '0' and s[i + 1] == '0':
					l = l + 1
					break
			if s[i] == '1':
				w = w + 1
			else:
				l = l + 1
		if w > l:
			print('WIN')
		else:
			print('LOSE')


for _ in range(int(input())):
	s = input()
	c = 0
	if s.count('1') > s.count('0'):
		print('WIN')
	else:
		print('LOSE')


for i in range(int(input())):
	match = input()
	chef = 0
	opp = 0
	for i in range(len(match)):
		if match[i] == '0':
			opp = opp + 1
		if match[i] == '1':
			chef = chef + 1
	if chef >= 11 and chef - opp >= 2:
		print('WIN')
	elif opp >= 11:
		print('LOSE')


t = int(input())
for _ in range(t):
	s = list(map(int, list(input())))
	x = sum(s)
	if len(s) - sum(s) < x:
		print('WIN')
	else:
		print('LOSE')


for _ in range(int(input())):
	s = input()
	if s[len(s) - 1] == '1':
		print('WIN')
	else:
		print('LOSE')