Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

In a world of superheroes each person is either a superhero or a villain. It is well known that every superhero has a name ending with either “man” or “woman”, for example “chefman”, “prettywoman” are Superheroes. All other persons are villains, for example “hacker” and “unclejohn". 

Currently a big fight between the superheroes and the villains is going to happen. Initially there is only one superhero fighting one villain. Then total of N persons joined the fight one after another. If at point of time, there are two more superheroes than villains in the fight, superheroes will win the fight immediately, as they can overwhelm villains with their powers. On the other hand, if there are 3 more villains than superheroes at any time, they will win, because they use dirty tricks to defeat the superheroes. If over all all the fights, none of these cases happen, then the fight is declared to be a draw. For a given list of people joining the fight in the given order, decide which groups wins the fight or whether the fight is ended with a draw. 

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

In the first line there is a single integer T denoting the number of test cases to handle. After that the description of T test cases follow.
Description of each test cases starts with a line containing a single integer N denoting the number of people joining the fight.
The i-th of the following N lines contains the name of person joining the fight at time i.

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

For each test cases, output either "superheroes" if superheroes win the fight, "villains" if villains win or a "draw" if the fight ends with a draw. All of these strings should be outputted without quotes.

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

$1 ≤ T ≤ 10$ 
$Every person's name consists only of English lowercase letters (i.e. from 'a' to 'z') and it is no longer than 15 characters.$
$No two persons have the same name.$

------ Subtasks ------ 

Subtask #1: (30 points)

$1 ≤ N ≤ 500$

Subtask #2: (70 points)

$1 ≤ N ≤ 10^{5}$

----- Sample Input 1 ------ 
3  
2   
kittywoman  
wingman  
6  
hacker  
beautywoman  
blackjack  
noname  
watersnake  
strongman  
4  
famousman  
redsnake  
tallwoman  
tinythief
----- Sample Output 1 ------ 
superheroes
villains
draw
----- explanation 1 ------ 
Example case 1. As you know that initially a superhero is fighting with a villain. After that, superhero "kittywoman" joins the fight. At this point, there are two superheros and one villain. After that "wingman" joins the fight too. As this point of time, there are three superheros and one villain, so the number of superheros are two more than number of villains, so superheros will win the fight. 
Example case 2. Other than first two peoople, six more people join the fight. The moment when the fight is decided is after watersnake joins the fight, because there are two superheroes fighting five villains, so villains will win.
Example case 3. Other than initial two people, four more people join the fight, and there is no moment at which the fight can be decided, so it ends with a draw.

Source: codechef | Difficulty: MEDIUM
Tags: String algorithms

Constructive algorithms

Data structures

Ad-hoc


Solutions:
def hero_or_villain(string):
	if string.endswith('man'):
		return 'hero'
	else:
		return 'villain'
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(input().strip())
	people = {'hero': 1, 'villain': 1}
	ans = 'draw'
	for i in a:
		people[hero_or_villain(i)] += 1
		if people['hero'] > people['villain'] + 1:
			ans = 'superheroes'
			break
		if people['hero'] + 2 < people['villain']:
			ans = 'villains'
			break
	print(ans)


t = int(input())
for _ in range(t):
	(counter, flag) = (0, -1)
	for _ in range(int(input())):
		s = input().strip()
		if s.endswith('man'):
			counter += 1
		else:
			counter -= 1
		if counter > 1 and flag == -1:
			flag = 1
		elif counter < -2 and flag == -1:
			flag = 0
	print('superheroes' if flag == 1 else 'villains' if flag == 0 else 'draw')


for tc in range(int(input())):
	n = int(input())
	(s, v) = (1, 1)
	status = 'draw'
	names = []
	for i in range(n):
		name = input().strip()
		names.append(name)
	for name in names:
		l = len(name)
		lname = name[l - 3:l]
		if lname == 'man':
			s += 1
		else:
			v += 1
		if s - v >= 2:
			status = 'superheroes'
			break
		if v - s >= 3:
			status = 'villains'
			break
	print(status)


for _ in range(int(input())):
	N = int(input())
	scount = 1
	vcount = 1
	draw_flag = 0
	for i in range(N):
		character = input()
		if character.strip().endswith('man'):
			scount += 1
		else:
			vcount += 1
		if draw_flag == 0:
			if scount > vcount and scount - vcount >= 2:
				print('superheroes')
				draw_flag = 1
				continue
			elif vcount > scount and vcount - scount >= 3:
				print('villains')
				draw_flag = 1
				continue
	if draw_flag == 0:
		print('draw')


t = int(input())
for iofj in range(t):
	n = int(input())
	f = [str(input()).strip() for rjhfb in range(n)]
	sup = 1
	vil = 1
	a = 0
	for i in f:
		if len(i) > 2 and i[-3:] == 'man':
			sup += 1
			if sup > vil + 1:
				a = 1
				print('superheroes')
				break
		else:
			vil += 1
			if vil > sup + 2:
				a = 1
				print('villains')
				break
	if a == 0:
		print('draw')


for _ in range(int(input())):
	N = int(input())
	s = []
	count = 0
	flag = True
	for i in range(N):
		s.append(input().strip())
	for i in range(N):
		if s[i].endswith('man'):
			count += 1
		else:
			count -= 1
		if count >= 2:
			print('superheroes')
			flag = False
			break
		elif count <= -3:
			print('villains')
			flag = False
			break
	if flag == True:
		print('draw')


g = int(input())
o = []
for hj in range(0, g):
	io = int(input())
	un = []
	for lp in range(0, io):
		kew = str(input())
		kew = kew.strip()
		un.append(kew)
	o.append(un)
for mvc in o:
	op = 1
	v = 1
	ck = 'draw'
	for ml in mvc:
		xr = ml[len(ml) - 3:len(ml)]
		if xr == 'man':
			op += 1
		else:
			v += 1
		if op > v:
			if op - v == 2:
				ck = 'superheroes'
				break
		if v > op:
			if v - op == 3:
				ck = 'villains'
				break
	print(ck)


for _ in range(int(input())):
	n = int(input())
	ch = 0
	cv = 0
	d = 0
	b = []
	for i in range(n):
		a = input()
		b.append(a.replace(' ', ''))
	for j in b:
		if j[-3:] == 'man':
			ch += 1
		else:
			cv += 1
		if ch - cv == 2:
			print('superheroes')
			d = 1
			break
		if cv - ch == 3:
			print('villains')
			d = 1
			break
	if d == 0:
		print('draw')


for _ in range(int(input())):
	k = int(input())
	a = 0
	b = 0
	c = 1
	d = 1
	l = []
	for i in range(k):
		l.append(input())
	for i in l:
		s1 = ''
		if i[-2:] == '  ':
			s1 = i[:-2]
		else:
			s1 = i
		if s1[-5:] == 'woman' or s1[-3:] == 'man':
			c += 1
		else:
			d += 1
		if c - d >= 2:
			print('superheroes')
			a += 1
			break
		elif d - c >= 3:
			print('villains')
			b += 1
			break
	if b == 0 and a == 0:
		print('draw')


T = int(input())
for I in range(T):
	s = 0
	v = 0
	flag = 0
	n = int(input())
	a = []
	f = {}
	for i in range(1, n + 1):
		i = input()
		a.append(i.replace(' ', ''))
	for i in a:
		if i.endswith('man'):
			s += 1
		else:
			v += 1
		if s >= v + 2:
			print('superheroes')
			flag = 1
			break
		if v >= s + 3:
			print('villains')
			flag = 1
			break
	if flag == 0:
		print('draw')


t = input()
for c in range(0, int(t)):
	n = int(input())
	hero_count = 0
	villian_count = 0
	hero = ['man', 'woman']
	flag = 0
	lis = []
	for x in range(n):
		a = input()
		lis.append(a.replace(' ', ''))
	for d in lis:
		if d[-3:] == 'man':
			hero_count += 1
		else:
			villian_count += 1
		if hero_count - villian_count == 2:
			flag = 1
			print('superheroes')
			break
		elif villian_count - hero_count == 3:
			flag = 2
			print('villains')
			break
	if flag == 0:
		print('draw')


T = int(input())
for i in range(T):
	n = int(input())
	(c, d, k) = (0, 0, 0)
	b = []
	for j in range(n):
		a = input()
		b.append(a.replace(' ', ''))
	for w in b:
		if w[-3:] == 'man':
			c += 1
		else:
			d += 1
		if c - d == 2:
			print('superheroes')
			k = 1
			break
		if d - c == 3:
			print('villains')
			k = 1
			break
	if k == 0:
		print('draw')


for i in range(int(input())):
	n = int(input())
	(h, v) = (1, 1)
	l1 = []
	res = 'draw'
	for i in range(n):
		ni = input().strip()
		l1.append(ni)
	for i in l1:
		if i[-3:] == 'man':
			h += 1
		else:
			v += 1
		if h - v == 2:
			res = 'superheroes'
			break
		elif v - h == 3:
			res = 'villains'
			break
	print(res)


for i in range(int(input())):
	no = int(input())
	sp = 1
	ls = []
	t = False
	for i in range(no):
		ls.append(input().strip())
	for i in ls:
		if i.endswith('man') or i.endswith('woman'):
			sp += 1
		else:
			sp -= 1
		if sp > 2:
			print('superheroes')
			t = True
			break
		if sp <= -2:
			print('villains')
			t = True
			break
	if not t:
		print('draw')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

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

def outp(n):
	sys.stdout.write(str(n) + '\n')

def outlt(lst):
	sys.stdout.write(' '.join(map(str, lst)) + '\n')

def outplt(lst):
	sys.stdout.write('\n'.join(map(str, lst)))

def outpltlt(lst):
	sys.stdout.write('\n'.join(map(str, (' '.join(map(str, a)) for a in lst))))
code = ['superheroes', 'villains', 'draw']
ans = []
for _ in range(inp()):
	N = inp()
	A = [insr() for x in range(N)]
	(s, v) = (0, 0)
	for a in A:
		if len(a) >= 3 and a[-3:] == 'man':
			s += 1
			if s - v == 2:
				ans.append(code[0])
				break
		else:
			v += 1
			if v - s == 3:
				ans.append(code[1])
				break
	else:
		ans.append(code[2])
outplt(ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	(flag, vil, hero) = (0, 1, 1)
	l = []
	for i in range(0, n):
		l.append(input().strip())
	for i in l:
		a = i
		if a[-3:] == 'man':
			hero = hero + 1
		else:
			vil = vil + 1
		if hero == vil + 2:
			print('superheroes')
			flag = 1
			break
		elif vil == hero + 3:
			print('villains')
			flag = 1
			break
	if flag == 0:
		print('draw')


t = int(input())
while t:
	t -= 1
	n = int(input())
	flag = 0
	(heroes, villians) = (1, 1)
	li = []
	for i in range(n):
		li.append(input().strip())
	for i in li:
		s = i
		if s[-3:] == 'man':
			heroes += 1
		else:
			villians += 1
		if villians - heroes == 3:
			flag = 1
			break
		elif heroes - villians == 2:
			flag = 2
			break
	if flag == 0:
		print('draw')
	elif flag == 1:
		print('villains')
	else:
		print('superheroes')


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for i in range(n):
		l.append(input())
	s = 1
	v = 1
	k = 0
	for i in l:
		i = i.strip()
		if i[-3:] == 'man':
			s += 1
		else:
			v += 1
		if s == v + 2:
			k = 1
			break
		elif v == s + 3:
			k = 2
			break
	if k == 1:
		print('superheroes')
	elif k == 2:
		print('villains')
	elif k == 0:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	fight_finished = False
	heroes = 0
	villians = 0
	ans = 'draw'
	for j in range(n):
		string = input().strip()
		if string[-3:] == 'man':
			heroes += 1
		else:
			villians += 1
		if not fight_finished:
			if heroes - villians >= 2:
				ans = 'superheroes'
				fight_finished = True
			if villians - heroes >= 3:
				ans = 'villains'
				fight_finished = True
	print(ans)


tests = int(input())
for i in range(tests):
	num = int(input())
	fight_finished = False
	heroes = 0
	villians = 0
	ans = 'draw'
	for j in range(num):
		string = input().strip()
		if len(string) < 3:
			villians += 1
		elif string[-3:] == 'man':
			heroes += 1
		else:
			villians += 1
		if not fight_finished:
			if heroes - villians >= 2:
				ans = 'superheroes'
				fight_finished = True
			if villians - heroes >= 3:
				ans = 'villains'
				fight_finished = True
	print(ans)


tst = int(input())
for i in range(tst):
	num = int(input())
	s = 1
	v = 1
	flag = 0
	for j in range(num):
		st = input()
		st = st.rstrip()
		if st[len(st) - 1] == 'n' and st[len(st) - 2] == 'a' and (st[len(st) - 3] == 'm'):
			s = s + 1
		else:
			v = v + 1
		if s >= v + 2:
			if flag == 0:
				print('superheroes')
				flag = 1
		elif v >= s + 3:
			if flag == 0:
				print('villains')
				flag = 1
	if flag != 1:
		print('draw')


t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	superhero = 1
	villain = 1
	for i in range(n):
		s = input()
		s = s.rstrip()
		num = len(s)
		if num < 3:
			villain = villain + 1
		elif s[-1] == 'n' and s[-2] == 'a' and (s[-3] == 'm'):
			superhero = superhero + 1
		else:
			villain = villain + 1
		if superhero == villain + 2:
			if ans == 0:
				ans = 1
		elif villain == superhero + 3:
			if ans == 0:
				ans = -1
	if ans == 1:
		print('superheroes')
	elif ans == -1:
		print('villains')
	else:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	villain = 0
	hero = 0
	ans = 'draw'
	for i in range(n):
		name = str(input())
		name = name.rstrip()
		len_ = len(name)
		if len_ < 3:
			villain += 1
		elif 'm' == name[-3] and 'a' == name[-2] and ('n' == name[-1]):
			hero += 1
		else:
			villain += 1
		if villain == hero + 3:
			if ans == 'draw':
				ans = 'villains'
		if hero == villain + 2:
			if ans == 'draw':
				ans = 'superheroes'
	print(ans)


for i in range(int(input())):
	n = int(input())
	(heroes, villans) = (1, 1)
	flag = True
	fighter = []
	for i in range(n):
		s = input()
		fighter.append(s)
	for li in fighter:
		li = li.rstrip()
		if li[-3:] == 'man':
			heroes += 1
		else:
			villans += 1
		if villans - heroes == 3:
			print('villains')
			flag = False
			break
		elif heroes - villans == 2:
			print('superheroes')
			flag = False
			break
	if flag:
		print('draw')


T = int(input())
for x in range(T):
	n = int(input())
	x = [input().strip() for i in range(n)]
	h = 0
	v = 0
	for na in x:
		if na[-3:] == 'man' or na[-5:] == 'woman':
			h += 1
		else:
			v += 1
		if h - v >= 2:
			print('superheroes')
			break
		elif v - h >= 3:
			print('villains')
			break
		if h + v == n:
			print('draw')


for _ in range(int(input())):
	n = int(input())
	x = [input().strip() for _ in range(n)]
	hero = 0
	villain = 0
	for name in x:
		if name[-3:] == 'man' or name[-5:] == 'woman':
			hero += 1
		else:
			villain += 1
		if hero - villain >= 2:
			print('superheroes')
			break
		elif villain - hero >= 3:
			print('villains')
			break
		if hero + villain == n:
			print('draw')


testCases = int(input())
for testCase in range(testCases):
	n = int(input())
	superheroes = 0
	villains = 0
	wins = 'draw'
	flag = False
	for _ in range(n):
		name = str(input().strip())
		if name[len(name) - 3:] == 'man':
			superheroes += 1
			if superheroes - villains >= 2 and flag is False:
				wins = 'superheroes'
				flag = True
		else:
			villains += 1
			if villains - superheroes >= 3 and flag is False:
				wins = 'villains'
				flag = True
	print(wins)


for _ in range(int(input())):
	n = int(input())
	superHero = villain = 1
	i = result = 0
	while i < n:
		i += 1
		person = input().replace(' ', '')
		k = len(person) - 3
		if person[k:] == 'man':
			superHero += 1
		else:
			villain += 1
		if superHero - villain >= 2:
			result = 1
			break
		elif villain - superHero >= 3:
			result = -1
			break
	while i < n:
		person = input()
		i += 1
	if result == 1:
		print('superheroes')
	elif result == -1:
		print('villains')
	else:
		print('draw')


T = int(input())
for i in range(T):
	N = int(input())
	lis = []
	count_super = 1
	count_villain = 1
	for i in range(N):
		lis.append(input().split())
	for enter in lis:
		test = enter[0]
		last_three = test[len(test) - 3:len(test)]
		last_five = test[len(test) - 5:len(test)]
		if str(last_three) == 'man' or str(last_five) == 'woman':
			count_super += 1
		else:
			count_villain += 1
		if count_super - count_villain >= 2:
			print('superheroes')
			break
		elif count_villain - count_super >= 3:
			print('villains')
			break
	else:
		print('draw')


for _ in range(int(input())):
	N = int(input())
	balance = 0
	for _ in range(N):
		if input().strip().endswith('man'):
			balance += 1
			if balance == 2:
				print('superheroes')
				for _ in range(_ + 1, N):
					input()
				break
		else:
			balance -= 1
			if balance == -3:
				print('villains')
				for _ in range(_ + 1, N):
					input()
				break
	else:
		print('draw')


for t in range(int(input())):
	n = int(input())
	(hero, villain, flag) = (1, 1, 0)
	for x in range(n):
		s = input().strip()
		if flag == 0:
			if len(s) < 3:
				villain += 1
			elif s[-1] == 'n' and s[-2] == 'a' and (s[-3] == 'm'):
				hero += 1
			else:
				villain += 1
			if hero - villain >= 2:
				print('superheroes')
				flag = 1
			elif villain - hero >= 3:
				print('villains')
				flag = 1
	if flag == 0:
		print('draw')


T = int(input())
for i in range(0, T):
	a = int(input())
	sh = 1
	sv = 1
	for j in range(0, a):
		b = input().split(' ')
		b = list(b[0])
		if len(b) >= 3 and b[-1] == 'n' and (b[-2] == 'a') and (b[-3] == 'm'):
			sh += 1
		else:
			sv += 1
		if sv > sh:
			if sv > sh + 2:
				print('villains')
				break
		elif sv < sh:
			if sv + 1 < sh:
				print('superheroes')
				break
	else:
		print('draw')
	for k in range(j + 1, a):
		b = input()


for i in range(int(input())):
	N = int(input())
	l = []
	for i in range(N):
		l.append(input().strip())
		soup = 0
		vil = 0
		draw = 0
	for i in range(N):
		if l[i].endswith('man' or 'woman'):
			soup += 1
		else:
			vil += 1
		if soup - vil >= 2:
			print('superheroes')
			break
		elif vil - soup >= 3:
			print('villains')
			break
		draw += 1
	if draw == N:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	list1 = []
	for _ in range(n):
		list1.append(input().strip())
		suph = 0
		vil = 0
		draw = 0
	for i in range(n):
		if list1[i].endswith('man' or 'woman'):
			suph += 1
		else:
			vil += 1
		if suph - vil >= 2:
			print('superheroes')
			break
		elif vil - suph >= 3:
			print('villains')
			break
		draw += 1
	if draw == n:
		print('draw')


def isHero(character):
	n = len(character)
	return character[n - 3:] == 'man' or character[n - 5:] == 'woman'

def winner(arr):
	(superHero, villen) = (0, 0)
	for character in arr:
		if isHero(character):
			superHero += 1
		else:
			villen += 1
		if superHero >= villen + 2:
			return 'superheroes'
		elif villen >= superHero + 3:
			return 'villains'
	return 'draw'
for _ in range(int(input())):
	n = int(input())
	characters = []
	for i in range(n):
		characters.append(input().strip())
	print(winner(characters))


for _ in range(int(input())):
	n = int(input())
	l = []
	for _ in range(n):
		l.append(input().strip())
	s = 0
	s1 = 0
	for i in range(n):
		if l[i].endswith('man' or 'woman'):
			s += 1
		else:
			s1 += 1
		if s - s1 >= 2:
			print('superheroes')
			break
		elif s1 - s >= 3:
			print('villains')
			break
	else:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	l = []
	for _ in range(n):
		l.append(input().strip())
	sh = 0
	v = 0
	for i in l:
		if i[-3:] == 'man':
			sh += 1
		else:
			v += 1
		if sh - v >= 2:
			print('superheroes')
			break
		elif v - sh >= 3:
			print('villains')
			break
	else:
		print('draw')


t = int(input())
for k in range(t):
	n = int(input())
	d = []
	(x, y) = (0, 0)
	p = 1
	for i in range(n):
		d.append(input().strip())
	for s in d:
		if s[-3:] == 'man' or s[-6:] == 'woman':
			x += 1
		else:
			y += 1
		if x >= y + 2:
			print('superheroes')
			p = 0
			break
		elif y >= x + 3:
			print('villains')
			p = 0
			break
	if p == 1:
		print('draw')


t = int(input())
for j in range(t):
	n = int(input())
	c = []
	(u, v) = (0, 0)
	p = 1
	for i in range(n):
		c.append(input().strip())
	for s in c:
		if s[-3:] == 'man':
			u += 1
		else:
			v += 1
		if u >= v + 2:
			print('superheroes')
			p = 0
			break
		elif v >= u + 3:
			print('villains')
			p = 0
			break
	if p == 1:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	good = 0
	bad = 0
	eq = 1
	lis = []
	for i in range(n):
		lis.append(input().strip())
	for j in lis:
		if j[-3:] == 'man':
			good = good + 1
		else:
			bad = bad + 1
		if good - bad >= 2:
			print('superheroes')
			eq = 0
			break
		elif bad - good >= 3:
			print('villains')
			eq = 0
			break
	if eq == 1:
		print('draw')


for _ in range(int(input())):
	a = int(input())
	l = []
	for i in range(a):
		l.append(input().strip())
	h = 0
	v = 0
	f = 1
	for i in l:
		if i[-3:] == 'man':
			h += 1
		else:
			v += 1
		if h - v >= 2:
			print('superheroes')
			f = 0
			break
		elif v - h >= 3:
			print('villains')
			f = 0
			break
	if f == 1:
		print('draw')


T = int(input())
for _ in range(T):
	N = int(input())
	arr = []
	for x in range(N):
		x = input()
		arr.append(x.strip())
	count_sup = 0
	count_vil = 0
	flag = 1
	for ele in arr:
		if ele[-3:] == 'man':
			count_sup += 1
		else:
			count_vil += 1
		if count_sup >= count_vil + 2:
			print('superheroes')
			flag = 0
			break
		elif count_vil >= count_sup + 3:
			print('villains')
			flag = 0
			break
	if flag == 1:
		print('draw')


t = int(input())
if t < 1 and t > 10:
	exit()
for i in range(t):
	n = int(input())
	heroes = []
	villains = []
	people = []
	for j in range(n):
		flag = 0
		people.append(input().strip())
	for k in range(n):
		if people[k].endswith('man') or people[k].endswith('woman'):
			heroes.append(people[k])
		else:
			villains.append(people[k])
		if len(heroes) + 1 - (len(villains) + 1) >= 2:
			print('superheroes')
			flag = 1
			break
		elif len(villains) + 1 - (len(heroes) + 1) >= 3:
			print('villains')
			flag = 1
			break
	if flag == 0:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	lis = []
	for i in range(n):
		lis.append(input().strip())
	flag = True
	c = 0
	k = 0
	for i in lis:
		if i[-3:] == 'man':
			c += 1
		else:
			k += 1
		if k - c >= 3:
			print('villains')
			flag = False
			break
		elif c - k >= 2:
			print('superheroes')
			flag = False
			break
	if flag:
		print('draw')


n = int(input())
for i in range(n):
	superHero = 0
	villan = 0
	flag = True
	num = int(input())
	arr = []
	for i in range(num):
		x = input().strip()
		arr.append(x)
	for i in arr:
		if i[-3:] == 'man':
			superHero += 1
		else:
			villan += 1
		if superHero - villan >= 2:
			print('superheroes')
			flag = False
			break
		elif villan - superHero >= 3:
			print('villains')
			flag = False
			break
	if flag:
		print('draw')


for _ in range(int(input())):
	n = int(input())
	s = 1
	v = 1
	ans = 'draw'
	f = 1
	for i in range(n):
		a = input().strip()
		if a.endswith('man'):
			s += 1
		else:
			v += 1
		if s - v >= 2 and f:
			ans = 'superheroes'
			f = 0
		elif v - s >= 3 and f:
			ans = 'villains'
			f = 0
	print(ans)


import sys
input = sys.stdin.readline

def rii():
	return range(int(input().strip()))

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

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())
superheroes_win = 'superheroes'
villains_win = 'villains'
neither_wins = 'draw'

def is_superhero(s):
	return True if any([s[-3:] == 'man', s[-5:] == 'woman']) else False

def solve(*args):
	(n, joining) = args
	balance = 0
	for fighter in joining:
		if is_superhero(fighter):
			balance += 1
			if balance == 2:
				return superheroes_win
		else:
			balance -= 1
			if balance == -3:
				return villains_win
	return neither_wins

def do_codechef():
	for t in rii():
		n = ii()
		joining = list()
		for _ in range(n):
			joining.append(si())
		print(solve(n, joining))
do_codechef()
exit()