Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i-th player contains m_{i} numbers.

During the game the host takes numbered balls one by one from a bag. He reads the number aloud in a high and clear voice and then puts the ball away. All participants cross out the number if it occurs on their cards. The person who crosses out all numbers from his card first, wins. If multiple people cross out all numbers from their cards at the same time, there are no winners in the game. At the beginning of the game the bag contains 100 balls numbered 1 through 100, the numbers of all balls are distinct.

You are given the cards for each player. Write a program that determines whether a player can win the game at the most favorable for him scenario or not.


-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 100) — the number of the players. Then follow n lines, each line describes a player's card. The line that describes a card starts from integer m_{i} (1 ≤ m_{i} ≤ 100) that shows how many numbers the i-th player's card has. Then follows a sequence of integers a_{i}, 1, a_{i}, 2, ..., a_{i}, m_{i} (1 ≤ a_{i}, k ≤ 100) — the numbers on the i-th player's card. The numbers in the lines are separated by single spaces.

It is guaranteed that all the numbers on each card are distinct.


-----Output-----

Print n lines, the i-th line must contain word "YES" (without the quotes), if the i-th player can win, and "NO" (without the quotes) otherwise.


-----Examples-----
Input
3
1 1
3 2 4 1
2 10 11

Output
YES
NO
YES

Input
2
1 1
1 1

Output
NO
NO

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
def contiene(l, s, n, m):
	j = 0
	for i in range(n):
		x = l[i]
		while j < m and (not l[i] == s[j]):
			j += 1
		if j == m and (not i == n):
			return False
	return True
n = int(input())
l = []
m = []
for i in range(n):
	s = [int(x) for x in input().split()]
	m.append(s[0])
	l.append(s[1:])
	l[i].sort()
for i in range(n):
	canWin = True
	for j in range(n):
		if not j == i:
			if m[i] < m[j]:
				continue
			if contiene(l[j], l[i], m[j], m[i]):
				canWin = False
				break
	if canWin:
		print('YES')
	else:
		print('NO')


n = int(input())
a = [set(list(map(int, input().split()))[1:]) for _ in range(n)]
res = 0
print(*['YES' if sum((i.issubset(j) for i in a)) == 1 else 'NO' for j in a], sep='\n')


n = int(input())
(t, l, s) = ([0] * n, [0] * n, ['YES'] * n)
for i in range(n):
	p = tuple(map(int, input().split()))
	(t[i], l[i]) = (set(p[1:]), p[0])
for i in range(n):
	for j in range(i + 1, n):
		if l[i] < l[j]:
			if all((k in t[j] for k in t[i])):
				s[j] = 'NO'
		elif all((k in t[i] for k in t[j])):
			if l[i] == l[j]:
				s[j] = 'NO'
			s[i] = 'NO'
print('\n'.join(s))


n = int(input())
cards = [[set(map(int, input().split()[1:])), i, True] for i in range(n)]
cards.sort(key=lambda x: len(x[0]))
for i in range(n - 1, -1, -1):
	if not cards[i][2]:
		continue
	for j in range(0, i):
		if cards[j][0] == cards[i][0]:
			cards[j][2] = cards[i][2] = False
			break
		if cards[j][0] < cards[i][0]:
			cards[i][2] = False
			break
cards.sort(key=lambda x: x[1])
for card in cards:
	print('YES' if card[2] else 'NO')


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
wr = stdout.write
rd = lambda : stdin.readline().strip()
all = []
n = int(rd())
for _ in range(n):
	all.append(set(map(int, rd().split()[1:])))
out = [True] * n
for i in range(n):
	for j in range(n):
		if i != j and all[i] <= all[j]:
			out[j] = False
for i in range(n):
	print('YES' if out[i] == True else 'NO')


n = int(input())
cards = [None] + [[] for i in range(n)]
for i in range(1, n + 1):
	cards[i] = list(map(int, input().split()))[1:]
ans = [None] + [True for i in range(n)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if i == j:
			continue
		if set(cards[i]) & set(cards[j]) == set(cards[j]):
			ans[i] = False
o = ''
for i in range(1, len(ans)):
	if ans[i] == True:
		o += 'YES\n'
	elif ans[i] == False:
		o += 'NO\n'
print(o)


from sys import stdin, stdout
from collections import Counter

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

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

def ip():
	return int(stdin.readline())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
a = []
for i in range(n):
	a.append(set(ai()[1:]))
for i in range(n):
	flag = 0
	for j in range(n):
		if i == j:
			continue
		elif a[j].issubset(a[i]):
			flag = 1
			break
	print('YES' if not flag else 'NO')


n = int(input())
p = list()
for i in range(n):
	p.append(set([int(x) for x in input().split()[1:]]))
for i in range(n):
	for j in range(n):
		if i != j:
			if p[i].issuperset(p[j]):
				print('NO')
				break
	else:
		print('YES')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
t = ii()
l = []
for i in range(t):
	(x, *y) = f()
	l.append(set(y))
for i in range(t):
	fg = 0
	for j in range(t):
		if i != j and len(l[i]) >= len(l[j]):
			if all((x in l[i] for x in l[j])):
				fg = 1
	print('YNEOS'[fg == 1::2])


n = int(input())
c = [[int(s) for s in input().split()][1:] for x in range(n)]
for i in range(n):
	for j in range(n):
		if i != j:
			for k in c[j]:
				if k not in c[i]:
					break
			else:
				print('NO')
				break
	else:
		print('YES')


n = int(input())
matrix = [[0 for x in range(101)] for y in range(n)]
for i in range(n):
	m = list(map(int, input().split(' ')))
	for j in range(1, len(m)):
		matrix[i][m[j] - 1] = 1
for i in range(n):
	ans = 'YES'
	for j in range(n):
		if i == j:
			continue
		for k in range(101):
			if matrix[i][k] == 0 and matrix[j][k] == 1:
				break
		if k == len(matrix[0]) - 1:
			ans = 'NO'
	print(ans)


p = [set(list(map(int, input().split()))[1:]) for i in range(int(input()))]
for (i, s) in enumerate(p):
	print('YES' if all((i == i2 or not s2 <= s for (i2, s2) in enumerate(p))) else 'NO')


n = int(input())
a = []
for x in range(n):
	m1 = input()
	m = m1.split(' ')
	b = []
	c = 0
	for y in m:
		if c != 0:
			b.append(int(y))
		c = c + 1
	a.append(b)
for z in range(n):
	lis1 = a[z]
	flag = 3
	count = 0
	for m in a:
		if z != count:
			if set(m).issubset(set(lis1)):
				flag = 2
		count = count + 1
	if flag == 2:
		print('NO')
	else:
		print('YES')


def main():
	n = int(input())
	a = [set(map(int, input().split()[1:])) for _ in range(n)]
	res = [True] * n
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i].issubset(a[j]):
				res[j] = False
			if a[i].issuperset(a[j]):
				res[i] = False
	print('\n'.join(('YES' if i else 'NO' for i in res)))

def __starting_point():
	main()
__starting_point()


a = []
n = int(input())
for i in range(n):
	a.append(set(list(map(int, input().split()))[1:]))
for i in range(n):
	possible = True
	for j in range(n):
		if i != j:
			if a[i] & a[j] == a[j]:
				possible = False
				break
	if possible:
		print('YES')
	else:
		print('NO')


import sys

def solve(info, n):
	for i in range(n):
		flag = False
		for j in range(n):
			if i == j:
				continue
			elif info[i].issuperset(info[j]):
				flag = True
				break
		if not flag:
			print('YES')
		else:
			print('NO')
i = sys.stdin.readline
n = int(i())
info = []
for _ in range(n):
	l = list(map(int, i().split()))
	info.append(set(l[1:]))
solve(info, n)


n = int(input())
(s, t) = (['YES'] * n, [set(map(int, input().split()[1:])) for i in range(n)])
for i in range(n):
	for j in range(n):
		if i != j and t[i].issuperset(t[j]):
			s[i] = 'NO'
			break
print('\n'.join(s))


n = int(input())
L = []
for i in range(n):
	m = list(map(int, input().split()))
	m = m[1:]
	L.append(sorted(m))
Ans = ['YES'] * n
for i in range(n):
	for j in range(n):
		if i == j:
			continue
		ind = -1
		for x in range(len(L[j])):
			if L[j][x] == L[i][0]:
				ind = x
				break
		if ind == -1:
			continue
		e = 0
		for x in range(ind, len(L[j])):
			if L[j][x] == L[i][e]:
				e += 1
			if e == len(L[i]):
				break
		if e == len(L[i]):
			Ans[j] = 'NO'
for i in range(n):
	print(Ans[i])


n = int(input())
a = []
m = []
p = []
mn = []
for i in range(n):
	b = list(map(int, input().split()))
	a.insert(i, b)
	m.append(a[i][0])
	a[i] = a[i][1:]
	mn.append(set(a[i]))
	p.append('YES')
for j in range(n):
	for i in range(n):
		if i != j:
			if mn[i] <= mn[j]:
				p[j] = 'NO'
				break
for i in range(n):
	print(p[i])


a = [sorted(list(map(int, input().split()))[1:]) for _ in range(int(input()))]
for i in range(len(a)):
	if any([all([elem in a[i] for elem in elema]) for elema in a[:i] + a[i + 1:]]):
		print('NO')
	else:
		print('YES')


n = int(input())
a = []
for i in range(n):
	a += [set(list(map(int, input().split()))[1:])]
for i in range(n):
	for j in range(n):
		if i != j and a[j] <= a[i]:
			print('NO')
			break
	else:
		print('YES')


3

def readln():
	return tuple(map(int, input().split()))
(n,) = readln()
lst = [set(readln()[1:]) for _ in range(n)]
for a in lst:
	print('YES' if len([1 for b in lst if len(a.union(b)) == len(a)]) == 1 else 'NO')


def subset(s1, s2):
	d = {}
	for i in s1:
		d[i] = 1
	flag = 0
	for i in s2:
		if i not in d:
			flag = 1
			break
	if flag == 0:
		return True
	else:
		return False
n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split()))[1:])
for i in range(n):
	ans = 'YES'
	for j in range(n):
		if i != j:
			if subset(l[i], l[j]):
				ans = 'NO'
				break
	print(ans)


n = int(input())
cards = list()
for i in range(n):
	cards.append(list())
	inp = [int(j) for j in input().split()]
	m = inp[0]
	inp.pop(0)
	inp.sort()
	cards[i] = inp
c_have_equal_num = list()
for i in range(n):
	c_have_equal_num.append(list())
	for j in range(i + 1, n):
		c_have_equal_num[i].append(int(0))

def num_is_in(num, card):
	num_is_in_card = False
	for ind in card:
		if ind > num:
			break
		elif ind == num:
			num_is_in_card = True
			break
	return num_is_in_card
for num in range(1, 101):
	for i in range(n):
		if num_is_in(num, cards[i]):
			for j in range(n - i - 1):
				if num_is_in(num, cards[i + j + 1]):
					c_have_equal_num[i][j] += 1
winnable = list()
for i in range(n):
	winnable.append(True)
for i in range(n):
	for j in range(n - i - 1):
		if c_have_equal_num[i][j] == len(cards[i]) and len(cards[i]) == len(cards[i + j + 1]):
			winnable[i + j + 1] = False
			winnable[i] = False
		elif c_have_equal_num[i][j] == len(cards[i + j + 1]):
			winnable[i] = False
		elif c_have_equal_num[i][j] == len(cards[i]):
			winnable[i + j + 1] = False
for i in winnable:
	if i:
		print('YES')
	else:
		print('NO')


k = int(input())
cards = []
res = []
for i in range(k):
	str = input()
	it = set(map(int, str.split(' ')[1:]))
	cards.append(it)
s = []
for i in cards:
	for j in cards:
		s.append(len(j.difference(i)))
	if s.count(0) != 1:
		print('NO')
	else:
		print('YES')
	s = []


n = int(input())
a = []
for i in range(n):
	li = list(map(int, input().split()))
	a.append(set(li[1:]))
for i in range(n):
	s = a[i]
	joke = 1
	for j in range(n):
		t = a[j]
		if t <= s and i != j:
			joke = 0
			break
	print('YES' * joke + 'NO' * (1 - joke))


a = int(input())
l = [list(map(int, input().split()[1:])) for _ in ' ' * a]
for i in range(a):
	for j in range(a):
		if i != j and all((k in l[i] for k in l[j])):
			print('NO')
			break
	else:
		print('YES')