Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them. 

There are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n universes has one Rick and one Morty. They're gathering in m groups. Each person can be in many groups and a group can contain an arbitrary number of members.

Ricks and Mortys have registered online in these groups. So, a person can have joined a group more than once (developer of this website hadn't considered this possibility). [Image] 

Summer from universe #1 knows that in each parallel universe (including hers) exactly one of Rick and Morty from that universe is a traitor and is loyal, but no one knows which one. She knows that we are doomed if there's a group such that every member in that group is a traitor (they will plan and destroy the world). 

Summer knows that if there's a possibility that world ends (there's a group where all members are traitors) she should immediately cancel this event. So she wants to know if she should cancel the event. You have to tell her yes if and only if there's at least one scenario (among all 2^{n} possible scenarios, 2 possible scenarios for who a traitor in each universe) such that in that scenario the world will end.


-----Input-----

The first line of input contains two integers n and m (1 ≤ n, m ≤ 10^4) — number of universes and number of groups respectively.

The next m lines contain the information about the groups. i-th of them first contains an integer k (number of times someone joined i-th group, k > 0) followed by k integers v_{i}, 1, v_{i}, 2, ..., v_{i}, k. If v_{i}, j is negative, it means that Rick from universe number  - v_{i}, j has joined this group and otherwise it means that Morty from universe number v_{i}, j has joined it.

Sum of k for all groups does not exceed 10^4.


-----Output-----

In a single line print the answer to Summer's question. Print "YES" if she should cancel the event and "NO" otherwise.


-----Examples-----
Input
4 2
1 -3
4 -2 3 2 -3

Output
YES

Input
5 2
5 3 -2 1 -1 5
3 -5 2 5

Output
NO

Input
7 2
3 -1 6 7
7 -5 4 2 4 7 -3 4

Output
YES



-----Note-----

In the first sample testcase, 1st group only contains the Rick from universe number 3, so in case he's a traitor, then all members of this group are traitors and so Summer should cancel the event.

Difficulty: EASY
Tags: Mathematics

Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def notafraid(list1):
	x = 0
	del list1[0]
	sorted(list1)
	for i in list1:
		if '-' + i in list1:
			x = 1
			break
	if x == 0:
		print('YES')
		quit()
	x = 0
(a, b) = input().split()
b = int(b)
for k in range(b):
	notafraid(input().split())
print('NO')


(n, m) = map(int, input().split())

def solve():
	for i in range(m):
		current = set(list(map(int, input().split()))[1:])
		for (a, j) in enumerate(current, 1):
			if -j in current:
				break
			elif a == len(current):
				return 'YES'
	return 'NO'
print(solve())


import sys

def solve():
	(n, m) = map(int, input().split())
	for i in range(m):
		(k, *a) = [int(j) for j in input().split()]
		a.sort(key=abs)
		if k == 1:
			print('YES')
			return
		for j in range(len(a) - 1):
			if a[j] == -a[j + 1]:
				break
		else:
			print('YES')
			return
	print('NO')

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def __starting_point():
	solve()
__starting_point()


(n, m) = list(map(int, input().split()))
for g in range(m):
	l = list(map(int, input().split()))
	s = set(l[1:])
	found = False
	for e in l[1:]:
		f = -e
		if f in s:
			found = True
			break
	if not found:
		print('YES')
		exit()
print('NO')


from math import *

def main():
	(n, m) = list(map(int, input().split()))
	hash = {}
	for i in range(0, m):
		array = list(map(int, input().split()))
		hash.clear()
		for j in range(1, len(array)):
			if not array[j] in hash:
				hash[array[j]] = 1
			if -array[j] in hash:
				break
		else:
			print('YES')
			break
	else:
		print('NO')
main()


(n, m) = [int(i) for i in input().split()]

def check(line):
	for i in line:
		if -i in line:
			return True
	return False
for _ in range(m):
	line = set([int(i) for i in input().split()][1:])
	if not check(line):
		print('YES')
		return
print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	q = 0
	l = list(map(int, input().split()))
	l = set(l[1:])
	for e in l:
		if -e not in l:
			continue
		else:
			q += 1
	if q == 0:
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	members = set(map(int, input().split()[1:]))
	if any((-x in members for x in members)):
		continue
	else:
		print('YES')
		exit(0)
print('NO')


(n, m) = list(map(int, input().split()))
dont_end = True
for _ in range(m):
	(k, *elements) = list(map(int, input().split()))
	some_set = set(elements)
	good = False
	for x in some_set:
		if -x in some_set:
			good = True
			break
	if not good:
		dont_end = False
if dont_end:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
for i in range(m):
	(k, *a) = list(map(int, input().split()))
	a = list(set(a))
	for i in range(len(a)):
		a[i] = abs(a[i])
	if len(set(a)) == len(a):
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
isDanger = False
for i in range(m):
	if isDanger:
		break
	isDanger = True
	l = input().split()
	k = int(l.pop(0))
	s = set()
	for no in l:
		no = int(no)
		if -no in s:
			isDanger = False
			break
		s.add(no)
if isDanger:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
f = 1
while m > 0:
	m -= 1
	l = list(map(int, input().split()))
	n = l[0]
	l = l[1:]
	pos = set()
	neg = set()
	for i in l:
		if i < 0:
			neg.add(i)
		else:
			pos.add(i)
	gflag = 0
	for i in pos:
		if 0 - i in neg:
			gflag = 1
			break
	for i in neg:
		if 0 - i in pos:
			gflag = 1
			break
	if gflag == 0:
		f = 0
		break
if f == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	l = list(map(int, input().split()))
	d = {}
	for i in l[1:]:
		d[i] = d.get(i, 0) + 1
	flag = True
	for i in d:
		if -i in d:
			flag = False
			break
	if flag:
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	members = list(map(int, input().split()))[1:]
	h1 = set()
	h2 = set()
	for m in members:
		if m < 0:
			h1.add(abs(m))
		else:
			h2.add(m)
	if not h1.intersection(h2):
		print('YES')
		exit(0)
print('NO')


(n, m) = map(int, input().split())
ans = 'NO'
for i in range(m):
	v = set(list(map(int, input().split()))[1:])
	ans = 'YES'
	for vi in v:
		if -vi in v:
			ans = 'NO'
			break
	if ans == 'YES':
		break
print(ans)


(n, m) = map(int, input().split())
for i in range(m):
	l = list(map(int, input().split()))
	k = l[0]
	del l[0]
	l = list(map(abs, set(l)))
	if len(l) == len(set(l)):
		print('YES')
		exit(0)
print('NO')


(a, b) = input().split()
b = int(b)
for k in range(b):
	l = list(map(int, input().split()))
	x = 0
	l.pop(0)
	while len(l) > 0:
		if -l[0] in l:
			x = 1
			break
		else:
			l.pop(0)
	if x == 0:
		print('YES')
		quit()
print('NO')


def main():
	(n, m) = map(int, input().split())
	for i in range(0, m):
		mk = True
		mp = set()
		ar = [int(i) for i in input().split()[1:]]
		for i in ar:
			if -i in mp:
				mk = False
				break
			mp.add(i)
		if mk:
			print('YES')
			return
	print('NO')
main()


(n, m) = map(int, input().split())
for i in range(m):
	d = list(map(int, input().split()))
	d.pop(0)
	d = set(d)
	for v in d:
		if -v in d:
			break
	else:
		print('YES')
		break
else:
	print('NO')


def compare(x):
	return abs(x)
a = []
(n, m) = map(int, input().split())
for i in range(m):
	x = list(map(int, input().split()))
	x = x[1:]
	a.append(x)
for i in range(0, len(a)):
	a[i].sort(key=compare)
for i in a:
	x = i[0]
	cnt = 0
	for j in i[1:]:
		if x + j != 0:
			cnt += 1
		x = j
	if cnt == len(i) - 1:
		print('YES')
		exit(0)
print('NO')


(n, m) = map(int, input().split(' '))
t = []
r = 'NO'
for i in range(m):
	l = list(map(int, input().split(' ')))[1:]
	t.append(l)
for i in t:
	rik = []
	morti = []
	if r == 'YES':
		break
	for j in i:
		if j < 0 and j not in rik:
			j = abs(j)
			rik.append(j)
			if j in morti:
				r = 'NO'
				break
			else:
				r = 'YES'
		elif j > 0 and j not in morti:
			morti.append(j)
			if j in rik:
				r = 'NO'
				break
			else:
				r = 'YES'
print(r)


(n, m) = map(int, input().split())
A = [0] * (2 * n + 1)
B = [0] * (2 * n + 1)
fl2 = 0
for i in range(m):
	fl = 0
	A = list(map(int, input().split()))
	for j in range(A[0]):
		B[A[j + 1]] = 1
		if B[-A[j + 1]] == 1:
			fl = 1
	if fl == 0:
		fl2 = 1
	B = [0] * (2 * n + 1)
if fl2 == 1:
	print('YES')
else:
	print('NO')


from collections import Counter as c
(a, b) = map(int, input().split())
for _ in ' ' * b:
	z = c(list(map(abs, set(map(int, input().split()[1:])))))
	if max(z.values()) == 1:
		exit(print('YES'))
print('NO')


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
for i in range(m):
	challengers = list(set(list(map(int, stdin.readline().split()))[1:]))
	s = set()
	label = 1
	for j in range(len(challengers)):
		if -challengers[j] in s:
			label = 0
		s.add(challengers[j])
	if label:
		stdout.write('YES')
		break
else:
	stdout.write('NO')


(n, m) = map(int, input().split())
dp_amount = 0
for i in range(m):
	array = list(map(int, input().split()))
	dp_array1 = [False] * n
	dp_array2 = [False] * n
	dp_proof = True
	for i in range(1, len(array)):
		if array[i] > 0:
			dp_array1[array[i] - 1] = True
		else:
			dp_array2[abs(array[i]) - 1] = True
		if dp_array2[abs(array[i]) - 1] and dp_array1[abs(array[i]) - 1]:
			dp_proof = False
			break
	if dp_proof:
		dp_amount += 1
		break
if dp_amount == 0:
	print('NO')
else:
	print('YES')


from collections import defaultdict
(n, m) = (int(x) for x in input().split())
all_fine = True
for i in range(m):
	rick = defaultdict(bool)
	morty = defaultdict(bool)
	fine = False
	a = [int(x) for x in input().split()][1:]
	for u in a:
		if u < 0:
			rick[-u] = True
		else:
			morty[u] = True
		if rick[abs(u)] and morty[abs(u)]:
			fine = True
	if not fine:
		all_fine = False
if all_fine:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
f = 1
for i in range(k):
	l = [int(i) for i in input().split()]
	l = l[1:]
	f = 0
	for i in l:
		if -i in l:
			f = 1
	if not f:
		print('YES')
		exit()
print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
groups = []
for i in range(m):
	raw = [int(x) for x in input().split()]
	groups.append(set(raw[1:]))
for group in groups:
	has_opposite = [-x in group for x in group]
	if not any(has_opposite):
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	l = list(map(int, input().split()))
	l = set(l[1:])
	for e in l:
		if -e in l:
			break
	else:
		print('YES')
		exit(0)
print('NO')


from sys import exit
(n, m) = tuple(map(int, input().split(' ')))
for i in range(m):
	li = list(map(int, input().split(' ')))
	k = li[0]
	rick = [False for e in range(1 + n)]
	morty = [False for e in range(1 + n)]
	evil = True
	for e in range(1, k + 1):
		if li[e] < 0:
			rick[abs(li[e])] = True
		else:
			morty[li[e]] = True
		if rick[abs(li[e])] and morty[abs(li[e])]:
			evil = False
			break
	if evil:
		print('YES')
		exit()
print('NO')


(n, m) = [int(i) for i in input().split()]
ok = 1 < 0
for i in range(m):
	m = {}
	l = [int(i) for i in input().split()]
	for k in l[1:]:
		if -k in m.keys():
			m[-k] = k
		elif k not in m.keys():
			m[k] = k
	for k in m.keys():
		if m[k] == -k:
			break
	else:
		ok = True
print('YES' if ok else 'NO')


def checkCancel(groupPeople):
	for i in groupPeople:
		if -i in groupPeople:
			return False
	return True
(n, m) = [int(s) for s in input().split(' ')]
cancel = False
for i in range(m):
	listElements = [int(s) for s in input().split(' ')]
	k = listElements[0]
	groupPeople = set(listElements[1:])
	posibleCancel = checkCancel(groupPeople)
	if posibleCancel:
		cancel = True
if cancel:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	for i in range(m):
		a = list(map(int, input().split()))
		b = dict()
		c = dict()
		f = True
		for j in range(1, a[0] + 1):
			if a[j] < 0:
				b[-a[j]] = 1
			else:
				c[a[j]] = 1
			if abs(a[j]) in b and abs(a[j]) in c:
				f = False
				break
		if f:
			print('YES')
			return
	print('NO')
main()


def __starting_point():
	(n, m) = list(map(int, input().split()))
	destroy = False
	while m > 0:
		group = [int(g) for g in input().split()][1:]
		if len(group) == 1:
			destroy = True
			break
		group = [abs(g) for g in list(set(group))]
		old_size = len(group)
		group = list(set(group))
		if len(group) == old_size:
			destroy = True
			break
		m -= 1
	if destroy:
		print('YES')
	else:
		print('NO')
__starting_point()


def func(arr, k):
	lst = [0] * (n + 2)
	for i in arr:
		if i >= 0:
			lst[i] = 1
	for i in arr:
		if i < 0:
			if lst[-i] == 1:
				return False
	return True
check = 0
(n, m) = map(int, input().split())
for i in range(m):
	(k, *arr) = list(map(int, input().split()))
	if func(arr, k):
		print('YES')
		check = 1
		break
if check == 0:
	print('NO')


(n, m) = map(int, input().split())
t = {i + 1: None for i in range(n)}
for j in range(m):
	flag = 0
	d = dict(t)
	l = list(map(int, input().split()))
	l = l[1:]
	for i in range(len(l)):
		if l[i] < 0 and d[-l[i]] == None:
			d[-l[i]] = l[i]
		elif l[i] > 0 and d[l[i]] == None:
			d[l[i]] = l[i]
		elif l[i] < 0 and d[-l[i]] >= 0:
			d[-l[i]] = 0
			flag = 1
		elif l[i] > 0 and d[l[i]] <= 0:
			d[l[i]] = 0
			flag = 1
	if flag == 0:
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
for _ in range(m):
	(k, *l) = map(int, input().split())
	l = set(l)
	for x in l:
		if -x in l:
			break
	else:
		print('YES')
		break
else:
	print('NO')


import sys
(n, m) = list(map(int, input().split()))
a = []
for _ in range(m):
	a.append(set(map(int, input().split()[1:])))
for i in a:
	for j in i:
		if -j in i:
			break
	else:
		print('YES')
		return
print('NO')


(n, m) = map(int, input().split(' '))
groupsAnswers = []
flag = True

def main(gropNum, rms):
	global flag, groupsAnswers
	Ricks = []
	Morties = []
	for man in rms:
		if man < 0:
			Ricks.append(abs(man))
		else:
			Morties.append(man)
	if flag:
		for Rick in Ricks:
			for Morty in Morties:
				if Rick == Morty:
					groupsAnswers.append('NO')
					return
		groupsAnswers.append('YES')
		flag = False
		return
for i in range(m):
	(gropNum, *rms) = map(int, input().split(' '))
	main(gropNum, rms)
if 'YES' in groupsAnswers:
	print('YES')
else:
	print('NO')


from collections import Counter
R = lambda : map(int, input().rstrip().split())
(n, m) = R()
mat = []
for _ in range(m):
	mat.append(list(R()))
for x in mat:
	c = Counter(x[1:x[0] + 1])
	flag = 0
	for y in c:
		if c[y] > 0 and c[-y] > 0:
			flag = 1
	if flag == 0:
		print('YES')
		exit()
print('NO')


def main():
	(n, m) = map(int, input().split())
	for i in range(m):
		numbers = tuple(map(int, input().split()))[1:]
		s = set()
		is_safe = False
		for t in numbers:
			if -t in s:
				is_safe = True
				break
			s.add(t)
		if is_safe == False:
			print('YES')
			return
	print('NO')
main()


(n, m) = map(int, input().split())
flag = 0
for i in range(m):
	arr = list(map(int, input().split()))
	d = {}
	for j in range(arr[0]):
		if -arr[j + 1] in d:
			flag += 1
			break
		else:
			d[arr[j + 1]] = True
if flag == m:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
for i in range(m):
	(k, *l) = map(int, input().split())
	l = set(l)
	for j in l:
		if -j in l:
			break
	else:
		exit(print('YES'))
print('NO')


import math
(n, m) = map(int, input().strip().split(' '))
f = 0
for i in range(m):
	lst = list(map(int, input().strip().split(' ')))
	l = ['0'] * n
	for j in range(1, len(lst)):
		if l[abs(lst[j]) - 1] == '0':
			if lst[j] > 0:
				l[abs(lst[j]) - 1] = 'p'
			else:
				l[abs(lst[j]) - 1] = 'n'
		elif l[abs(lst[j]) - 1] == 'p' and lst[j] < 0:
			l[abs(lst[j]) - 1] = 'b'
		elif l[abs(lst[j]) - 1] == 'n' and lst[j] > 0:
			l[abs(lst[j]) - 1] = 'b'
	if 'b' not in l:
		f = 1
		print('YES')
		break
if f == 0:
	print('NO')


from sys import stdin, stdout
doomed = False
(n, m) = list(map(int, stdin.readline().rstrip().split()))
for _ in range(m):
	groupInfo = [int(a) for a in stdin.readline().rstrip().split()]
	groupSet = set()
	doomGroup = True
	for i in groupInfo[1:]:
		if -i in groupSet:
			doomGroup = False
			break
		else:
			groupSet.add(i)
	if doomGroup:
		doomed = True
if doomed:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
glflag = False
for i in range(m):
	arr = list(map(int, input().split()))
	used = [0] * n
	flag = False
	for j in range(1, len(arr)):
		if arr[j] * used[abs(arr[j]) - 1] < 0:
			flag = True
			break
		elif arr[j] < 0:
			used[abs(arr[j]) - 1] = -1
		else:
			used[abs(arr[j]) - 1] = 1
	if not flag:
		print('YES')
		glflag = True
		break
if not glflag:
	print('NO')


(n, m) = map(int, input().split())
for _ in range(m):
	q = list(map(int, input().split()))
	q = q[1:]
	alen = len(set(q))
	q = list(map(abs, q))
	if alen == len(set(q)):
		print('YES')
		exit()
print('NO')


ins = map(int, input().split())
(n, m) = (next(ins), next(ins))
cnt = [0] * 20010
cancel = False
for _ in range(m):
	line = list(map(int, input().split()))
	done = False
	for i in range(1, len(line)):
		if line[i] > 0:
			cnt[line[i] + 10000] = 1
			if cnt[line[i]] == 1:
				done = True
				break
		else:
			cnt[abs(line[i])] = 1
			if cnt[abs(line[i]) + 10000] == 1:
				done = True
				break
	if not done:
		cancel = True
	for i in range(1, len(line)):
		(cnt[abs(line[i])], cnt[abs(line[i]) + 10000]) = (0, 0)
if cancel:
	print('YES')
else:
	print('NO')


(n, m) = [int(j) for j in input().split()]
flag = 0
c = 0
for k in range(m):
	seen = set()
	x = [int(j) for j in input().split()]
	x = x[1:]
	x = list(set(x))
	y = [abs(int(a)) for a in x]
	if (not any((i in seen or seen.add(i) for i in y))) == True:
		flag = 1
		break
	else:
		c += 1
if flag == 1:
	print('YES')
if c == m:
	print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	a = list(map(int, input().split()))
	a = a[1:]
	used = set()
	st = False
	for j in a:
		if -j in used:
			st = True
		else:
			used.add(j)
	if not st:
		break
if st:
	print('NO')
else:
	print('YES')


import sys

def is_dangerous(group):
	finded = [0] * 10001
	if len(group) < 2:
		return True
	for e in group:
		universe = e if e > 0 else -e
		if finded[universe] != 0 and finded[universe] != e:
			return False
		finded[universe] = e
	return True
[n, m] = [int(x) for x in input().split(' ')]
groups = [[]] * m
for g in range(m):
	groups[g] = [int(x) for x in input().split(' ')]
	groups[g].pop(0)
for group in groups:
	if is_dangerous(group):
		print('YES')
		sys.exit()
print('NO')
sys.exit()


(n, m) = map(int, input().split())
c = False
for i in range(m):
	flag = True
	g = list(map(int, input().split()))[1:]
	if c:
		continue
	g = list(set(g))
	g.sort(key=lambda x: abs(x))
	for i in range(len(g) - 1):
		if g[i] == -g[i + 1]:
			flag = False
			break
	if flag:
		c = True
if c:
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, m) = map(int, input().split())
lst = []
for i in range(m):
	a = list(map(int, input().split()))[1:]
	n = len(a)
	d = defaultdict(int)
	s = 'YES'
	for j in range(n):
		if d[-a[j]]:
			s = 'NO'
		d[a[j]] += 1
	lst.append(s)
print('YES' if 'YES' in lst else 'NO')


(n, m) = list(map(int, input().split()))
for i in range(m):
	good = 0
	morty = set()
	rick = set()
	now = list(map(int, input().split()))[1:]
	for c in now:
		if c < 0:
			morty.add(abs(c))
			if abs(c) in rick:
				good = 1
		if c > 0:
			rick.add(abs(c))
			if abs(c) in morty:
				good = 1
	if not good:
		print('YES')
		return
print('NO')


from bisect import bisect_left

def binary_search(a, x, lo=0, hi=None):
	hi = hi if hi is not None else len(a)
	pos = bisect_left(a, x, lo, hi)
	return pos if pos != hi and a[pos] == x else -1
(n, m) = map(int, input().split())
pos = False
for _ in range(m):
	(k, *l) = list(map(int, input().split()))
	riks = sorted([x for x in l if x > 0])
	morts = sorted([-x for x in l if x < 0])
	s = []
	if len(riks) > len(morts):
		for m in morts:
			if binary_search(riks, m) != -1:
				pos = True
				break
		if not pos:
			print('YES')
			break
		pos = False
	else:
		for r in riks:
			if binary_search(morts, r) != -1:
				pos = True
				break
		if not pos:
			print('YES')
			break
		pos = False
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
for _ in range(m):
	l = [int(x) for x in input().split()][1:]
	s = set(l)
	ok = False
	for i in l:
		if -i in s:
			ok = True
			break
	if not ok:
		print('YES')
		sys.exit(0)
print('NO')


(n, m) = map(int, input().split())
flag1 = 0
for i in range(m):
	a = list(map(int, input().split()))
	a = set(a[1:])
	flag = 0
	for x in a:
		if -x in a:
			flag = 1
			break
	if not flag:
		flag1 = 1
		break
print('YES' if flag1 else 'NO')


(n, m) = (int(x) for x in input().split())
res = False
for l in range(m):
	(k, *a) = (int(x) for x in input().split())
	safe = False
	mem = []
	for i in range(len(a)):
		if -a[i] in mem:
			safe = True
			break
		else:
			mem.append(a[i])
	if not safe:
		res = True
print('YES' if res else 'NO')


from collections import Counter, defaultdict

def main():
	(n, m) = [int(i) for i in input().split()]
	for _ in range(m):
		lista = defaultdict(lambda : False)
		for i in input().split()[1:]:
			lista[i] = True
		meh = Counter([abs(int(i)) for i in lista]).most_common(1)
		if meh[0][1] == 1:
			print('YES')
			return None
	print('NO')
main()


(n, m) = map(int, input().split())
for _ in range(m):
	v = sorted(set(map(int, input().split()[1:])))
	if len(v) == 2 and v[0] != -v[1]:
		print('YES')
		quit()
	(x, y) = (0, len(v) - 1)
	while x < y:
		while y - 1 > x and v[x] + v[y - 1] >= 0:
			y -= 1
		if v[x] + v[y] == 0:
			break
		elif x < len(v) - 1:
			x += 1
		else:
			break
	if x >= y:
		print('YES')
		quit()
print('NO')


(n, m) = map(int, input().split())
flag = True
for i in range(m):
	t = list(map(int, input().split()))
	if flag:
		del t[0]
		p = list(set(t))
		length = len(p)
		kk = set()
		for a in p:
			kk.add(abs(a))
		if len(kk) == length:
			flag = False
			print('YES')
if flag:
	print('NO')


(n, m) = map(int, list(input().split()))
for i in range(0, m):
	ar = list(input().split())
	st = set()
	for j in range(1, len(ar)):
		st.add(int(ar[j]))
	found = False
	for x in st:
		if -x in st:
			found = True
	if found == False:
		print('YES')
		exit(0)
print('NO')
exit(0)


(n, k) = map(int, input().split(' '))
for i in range(k):
	m = set(list(map(int, input().split(' ')))[1:])
	for x in m:
		if -x in m:
			break
	else:
		print('YES')
		break
else:
	print('NO')


(n, m) = map(int, input().split())
ans = 'NO'
for i in range(m):
	a = list(map(int, input().split()))[1:]
	s = set()
	new_ans = False
	for j in range(len(a)):
		s.add(a[j])
		if -a[j] in s:
			new_ans = True
			break
	if not new_ans:
		ans = 'YES'
		break
print(ans)


(n, m) = map(int, input().split())
for i in range(m):
	qq = list(map(int, input().split()))
	qq = qq[1:]
	aaa = len(set(qq))
	qq = list(map(abs, qq))
	if aaa == len(set(qq)):
		print('YES')
		exit(0)
print('NO')


from math import inf
(n, m) = [int(x) for x in input().split()]
bad = False
ars = []
for i in range(m):
	(k, *ar) = [int(x) for x in input().split()]
	ars.append(ar)
for ar in ars:
	pol = set()
	otr = set()
	for x in ar:
		if x > 0:
			pol.add(x)
		else:
			otr.add(-x)
	if len(pol & otr) == 0:
		bad = True
		break
print('YES' if bad else 'NO')


nm = [int(x) for x in input().split()]
for i in range(0, nm[1]):
	lista = [int(x) for x in input().split()]
	lista = lista[1:len(lista)]
	s = set(lista)
	lista = [abs(i) for i in lista]
	if len(s) == len(set(lista)):
		print('YES')
		break
else:
	print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	(a, *b) = map(int, input().split())
	b = set(b)
	for j in b:
		if -j in b:
			break
	else:
		print('YES')
		break
else:
	print('NO')


from collections import Counter as c
(a, b) = map(int, input().split())
for _ in ' ' * b:
	(c, *d) = map(int, input().split())
	for i in d:
		if -i in d:
			break
	else:
		exit(print('YES'))
print('NO')


import sys

def possibly_all_traitors(group):
	member_set = set()
	for member in group[1:]:
		if -member in member_set:
			return False
		else:
			member_set.add(member)
	return True
in1 = input()
in_str = in1.split()
planets = int(in_str[0])
groups = int(in_str[1])
for i in range(groups):
	g = list(map(int, input().split()))
	if possibly_all_traitors(g):
		print('YES')
		sys.exit(0)
print('NO')


(n, m) = map(int, input().split())

def main():
	for i in range(m):
		g = list(map(int, input().split()))
		k = g[0]
		free = set()
		maybe = True
		for j in range(1, k + 1):
			if -g[j] in free:
				maybe = False
				break
			else:
				free.add(g[j])
		if len(free) > 0 and maybe:
			return 'YES'
	return 'NO'
print(main())


(n, m) = list(map(int, input().split()))
ls = [list(map(int, input().split())) for _ in range(m)]
ans = 'NO'
for kv in ls:
	k = kv[0]
	v = kv[1:]
	s = set(v)
	if len(s) == len(set(map(abs, s))):
		ans = 'YES'
		break
print(ans)


def main():
	(n, m) = map(int, input().split())
	for _ in range(m):
		(_, *l) = input().split()
		rm = set()
		for a in l:
			if a[0] == '-':
				if a[1:] in rm:
					break
			elif '-' + a in rm:
				break
			rm.add(a)
		else:
			print('YES')
			return
	print('NO')
main()


(k, m) = map(int, input().split())
for i in range(m):
	x = False
	a = list(map(int, input().split()))
	a.remove(a[0])
	for char in a:
		if -1 * char in a:
			x = True
			break
	if not x:
		break
if x:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
for i in range(m):
	p = [int(x) for x in input().split()]
	p = set(p[1:])
	found = False
	for x in p:
		if -x in p:
			found = True
			break
	if not found:
		print('YES')
		exit(0)
print('NO')


(n, m) = map(int, input().split())
for i in range(m):
	a = list(map(int, input().split()))
	s = set()
	for i in range(1, len(a)):
		s.add(a[i])
	k = list(s)
	isok = 0
	for i in range(len(k)):
		if -k[i] in s:
			isok = 1
	if not isok:
		print('YES')
		exit(0)
print('NO')


R = lambda : list(map(int, input().split()))
(n, m) = R()
a = 0
while m > 0 and a == 0:
	b = R()[1:]
	(d, k) = (dict(), 0)
	for i in b:
		if -i in d:
			k = 1
		d[i] = 1
	if k == 0:
		a = 1
	m -= 1
print('NO' if a == 0 else 'YES')


(n, m) = map(int, input().split())
bad = 0
for _ in range(m):
	v = [0] * (n + 1)
	ok = 0
	for u in [int(i) for i in input().split()[1:]]:
		au = abs(u)
		su = 1 if u < 0 else 2
		v[au] |= su
		if v[au] == 3:
			ok = 1
	if not ok:
		bad = 1
print('YES' if bad else 'NO')


(n, m) = map(int, input().split())
flag = 0
for i in range(m):
	s = 0
	q = set()
	a = list(map(int, input().split()))
	for item in a[1:]:
		if -item in q:
			s = 1
		q.add(item)
	if s == 0:
		flag = 1
if flag:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ans = 'NO'
for i in range(m):
	arr = list(map(int, input().split()))
	map_it = dict()
	flag = True
	for j in range(1, arr[0] + 1):
		if arr[j] not in map_it:
			map_it.update({arr[j]: True})
	for j in range(1, arr[0] + 1):
		if arr[j] in map_it and -arr[j] in map_it:
			flag = False
			break
	if flag:
		ans = 'YES'
print(ans)


(n, m) = map(int, input().split())
for i in range(m):
	members = set(map(int, input().split()[1:]))
	if all((-x not in members for x in members)):
		print('YES')
		exit(0)
print('NO')


import sys

def isDoomed(l):
	s = set(l)
	for e in s:
		if -e in s:
			return False
	return True
(n, m) = map(int, input().split())
for mm in range(m):
	l = list(map(int, input().split()))[1:]
	if isDoomed(l):
		print('YES')
		return
print('NO')


s = input().split()
(n, m) = map(int, s)
groups = []
for i in range(m):
	s = input().split()
	s = list(map(int, s))
	k = s[0]
	vi = set(s[1:])
	groups.append(vi)

def check_safe(group):
	for v in group:
		if -v in group:
			return True
	return False
should_cancel = 'NO'
for g in groups:
	if not check_safe(g):
		should_cancel = 'YES'
		break
print(should_cancel)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(a, b) = I()
for tc in range(b):
	temp = set(I()[1:])
	s = set(map(abs, temp))
	if len(temp) == len(s):
		print('YES')
		sys.exit()
print('NO')


(n, m) = map(int, input().split())
for j in range(m):
	s = set(map(int, input().split()[1:]))
	if all((-x not in s for x in s)):
		print('YES')
		exit()
print('NO')


def solution(vals):
	lis = []
	for val in vals:
		if -val not in lis:
			lis.append(val)
		else:
			return False
	return True

def main():
	(universos, grupos) = [int(x) for x in input().split()]
	for i in range(grupos):
		(n, *vals) = [int(x) for x in input().split()]
		if solution(vals):
			print('YES')
			return
	print('NO')
main()


R = lambda : map(int, input().split())
(n, m) = R()
for _ in range(m):
	x = set(list(R())[1:])
	l = set(map(abs, x))
	if len(x) == len(l):
		print('YES')
		exit()
print('NO')


(x, y) = map(int, input().split())
arr1 = []
flag1 = 0
for i in range(0, y):
	arr1 = [0] * x
	arr = list(map(int, input().split()))
	x1 = arr[0]
	del arr[0]
	arr = list(set(arr))
	flag = 0
	for i in range(0, len(arr)):
		arr1[abs(arr[i]) - 1] += 1
		if arr1[abs(arr[i]) - 1] > 1:
			flag = 1
			break
	if flag == 0:
		flag1 = 1
	arr1 = []
if flag1 == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
traitors = []
for i in range(m):
	traitor = True
	group = list(set(input().split()[1:]))
	group = list(map(lambda x: abs(int(x)), group))
	group.sort()
	for i in range(1, len(group)):
		if group[i - 1] == group[i]:
			traitor = False
	if traitor:
		traitors.append(0)
if traitors:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	ans = False
	for _ in range(m):
		group = list(map(int, input().split()))[1:]
		group = set(group)
		safe = False
		for x in group:
			if -x in group:
				safe = True
		ans = ans or not safe
	print('YES' if ans else 'NO')
main()


(n, m) = map(int, input().split(' '))
ans = False
for i in range(m):
	psg = []
	(k, *psg) = map(int, input().split(' '))
	ok = False
	s = set()
	for j in range(k):
		if -psg[j] in s:
			ok = True
			break
		else:
			s.add(psg[j])
	if not ok:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


read = lambda : map(int, input().split())
(n, m) = read()
for i in range(m):
	arr = set(list(read())[1:])
	arr = [abs(int(i)) for i in arr]
	if len(arr) == len(set(arr)):
		print('YES')
		break
else:
	print('NO')


(n, m) = map(int, input().split())
ans = []
for i in range(m):
	l = list(map(int, input().split()))
	k = l.pop(0)
	if k == 1:
		ans.append('YES')
		break
	else:
		flag = 0
		d = {}
		for i in l:
			d[i] = 1
		for i in l:
			try:
				if d[-i] == 1:
					ans.append('NO')
					flag = 1
					break
			except:
				pass
		if flag == 0:
			ans.append('YES')
			break
print('YES' if 'YES' in ans else 'NO')


(n, m) = map(int, input().split())
l_g = list((list(map(int, input().split())) for i in range(m)))
for g in l_g:
	s = set()
	b = False
	for i in range(1, len(g)):
		if -g[i] not in s:
			s.add(g[i])
		else:
			b = True
			break
	if not b:
		print('YES')
		quit()
print('NO')


def test(l):
	l1 = []
	l2 = []
	for i in range(len(l)):
		if l[i] < 0 and l[i] not in l2:
			l2.append(l[i])
		elif l[i] > 0 and l[i] not in l1:
			l1.append(l[i])
	if len(l1) == 0 or len(l2) == 0:
		return False
	for x in l1:
		if x * -1 in l2:
			return True
	for x in l2:
		if x * -1 in l1:
			return True
	return False
(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
for t_0 in range(m):
	list1 = list(map(int, input().strip().split(' ')))
	if test(list1[1:]) == False:
		print('YES')
		exit()
print('NO')


(N, M) = map(int, input().split())
for _1 in range(M):
	A = list(map(int, input().split()))[1:]
	(bag, found) = (set(), False)
	for v in A:
		if -v in bag:
			found = True
		bag.add(v)
	if not found:
		exit(print('YES'))
print('NO')


from sys import stdin, stdout
from collections import defaultdict

def ri():
	return map(int, input().split())
(n, m) = ri()
for i in range(m):
	aa = defaultdict(lambda : set())
	a = list(ri())
	for i in range(1, len(a)):
		aa[abs(a[i])].add(a[i])
		if len(aa[abs(a[i])]) > 1:
			break
	else:
		print('YES')
		exit()
print('NO')


(n, m) = (int(v) for v in input().split())
for i in range(m):
	s = set([int(v) for v in input().split()][1:])
	if len(s) == len({abs(v) for v in s}):
		print('YES')
		exit(0)
print('NO')


[n, m] = list(map(int, input().split()))
for i in range(m):
	str = list(map(int, input().split()))
	l = str[0]
	s = str[1:]
	a = [0 for i in range(n + 1)]
	b = [0 for i in range(n + 1)]
	for j in range(l):
		if s[j] > 0:
			a[s[j]] += 1
		else:
			b[-s[j]] += 1
	ok = False
	for j in range(n + 1):
		if a[j] > 0 and b[j] > 0:
			ok = True
	if ok == False:
		print('YES')
		exit(0)
print('NO')


import sys
(n, m) = map(int, input().split())
p = 0
for i in range(m):
	(k, *l) = map(int, input().split())
	l = set(l)
	p = 0
	for x in l:
		if -x in l:
			p = 1
			break
	if p == 0:
		print('Yes')
		exit(0)
print('NO')


(n, m) = [int(a_temp) for a_temp in input().strip().split()]
p = []
for i in range(m):
	p.append([int(a_temp) for a_temp in input().strip().split()])
for i in range(m):
	traitor = True
	d = {}
	for e in p[i][1:]:
		d[e] = True
		if -1 * e in d:
			traitor = False
			break
	if traitor:
		print('YES')
		break
if not traitor:
	print('NO')


from bisect import bisect_left

def bins2(arr, x, bot, top=None):
	top = top if top is not None else len(arr)
	pos = bisect_left(arr, x, bot, top)
	return pos != top and arr[pos] == x

def bins(arr, x):
	return bins2(arr, x, 0)

def ins(arr, x):
	index = bisect_left(arr, x, 0, len(arr))
	if index == len(arr) or arr[index] != x:
		arr.insert(index, x)

def solve():
	(n, m) = map(int, input().split(' '))
	for a0 in range(m):
		s = list(map(int, input().split(' ')))
		seen_plus = []
		seen_minus = []
		all_good = False
		for (i, x) in enumerate(s):
			if i == 0:
				continue
			if x < 0:
				if bins(seen_plus, -x):
					all_good = True
					break
				ins(seen_minus, x)
			else:
				if bins(seen_minus, -x):
					all_good = True
					break
				ins(seen_plus, x)
		if not all_good:
			return 'YES'
	return 'NO'
print(solve())


(n, m) = (int(x) for x in input().strip().split(' '))
groups = []
for _ in range(m):
	group = [int(x) for x in input().strip().split(' ')][1:]
	groups.append(group)

def verify_group(group):
	checked = set([])
	for x in group:
		if -x in checked:
			return True
		checked.add(x)
	return False
result = True
for group in groups:
	if not verify_group(group):
		result = False
		break
print('NO') if result else print('YES')


inp = input().split()
notAfraid = False
for i in range(int(inp[1])):
	inpp = input().split()
	index = int(inpp[0])
	tmp = {}
	tmpx = {}
	for j in range(index):
		tmpp = int(inpp[j + 1])
		if abs(tmpp) not in tmp:
			notAfraid = False
			tmpx[tmpp] = 1
			tmp[abs(tmpp)] = 1
		elif abs(tmpp) in tmp and tmpp not in tmpx:
			notAfraid = True
			break
	if not notAfraid:
		break
print('NO' if notAfraid else 'YES')


(n, m) = map(int, input().split())
for i in range(m):
	bad = True
	l = set(map(int, input().split()[1:]))
	for j in l:
		if -j in l:
			bad = False
			break
	if bad:
		break
print('YES' if bad else 'NO')