Toad Ivan has $m$ pairs of integers, each integer is between $1$ and $n$, inclusive. The pairs are $(a_1, b_1), (a_2, b_2), \ldots, (a_m, b_m)$. 

He asks you to check if there exist two integers $x$ and $y$ ($1 \leq x < y \leq n$) such that in each given pair at least one integer is equal to $x$ or $y$.


-----Input-----

The first line contains two space-separated integers $n$ and $m$ ($2 \leq n \leq 300\,000$, $1 \leq m \leq 300\,000$) — the upper bound on the values of integers in the pairs, and the number of given pairs.

The next $m$ lines contain two integers each, the $i$-th of them contains two space-separated integers $a_i$ and $b_i$ ($1 \leq a_i, b_i \leq n, a_i \neq b_i$) — the integers in the $i$-th pair.


-----Output-----

Output "YES" if there exist two integers $x$ and $y$ ($1 \leq x < y \leq n$) such that in each given pair at least one integer is equal to $x$ or $y$. Otherwise, print "NO". You can print each letter in any case (upper or lower).


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

Output
NO

Input
5 4
1 2
2 3
3 4
4 5

Output
YES

Input
300000 5
1 2
1 2
1 2
1 2
1 2

Output
YES



-----Note-----

In the first example, you can't choose any $x$, $y$ because for each such pair you can find a given pair where both numbers are different from chosen integers.

In the second example, you can choose $x=2$ and $y=4$.

In the third example, you can choose $x=1$ and $y=2$.

Source: codeforces | Difficulty: MEDIUM
Tags: Graph algorithms

Implementation


Solutions:
(n, m) = map(lambda x: int(x), input().split())
c = 0
l = []
for i in range(m):
	l.append(set(map(lambda x: int(x), input().split())))
for e in l[0]:
	for i in range(0, m):
		if e not in l[i]:
			for el in l[i]:
				for j in range(i, m):
					if el not in l[j] and e not in l[j]:
						c += 1
						break
			break
if c == 4:
	print('NO')
else:
	print('YES')


(m, n) = map(int, input().split())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
isk = (a[0][0], a[0][1])
for i in range(2):
	d = isk[i]
	ans = 0
	dd = [0] * (m + 1)
	for j in a:
		if j[0] != d and j[1] != d:
			dd[j[0]] += 1
			dd[j[1]] += 1
			ans += 1
	if max(dd) >= ans:
		print('YES')
		exit()
print('NO')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
number = [list(map(int, input().split())) for _ in range(m)]
a = number[0][0]
b = number[0][1]
if a > n and b > n:
	print('NO')
else:
	flaga1 = 1
	flaga2 = 1
	flagb1 = 1
	flagb2 = 1
	count = 0
	if a <= n:
		c = a
		d = a
		for i in number:
			if a not in i:
				c = i[0]
				d = i[1]
				break
		for i in number:
			if a not in i and d not in i:
				flaga1 = 0
				break
		for i in number:
			if a not in i and c not in i:
				flaga2 = 0
				break
	if b <= n:
		c = b
		d = b
		for i in number:
			if b not in i:
				c = i[0]
				d = i[1]
				break
		for i in number:
			if b not in i and d not in i:
				flagb1 = 0
				break
		for i in number:
			if b not in i and c not in i:
				flagb2 = 0
				break
	if flaga1 == 0 and flaga2 == 0 and (flagb1 == 0) and (flagb2 == 0):
		print('NO')
	else:
		print('YES')


import collections, heapq, sys
(n, m) = map(int, sys.stdin.readline().rstrip().split(' '))
a = []
for _ in range(m):
	(x, y) = map(int, sys.stdin.readline().rstrip().split(' '))
	a.append([x, y])
(x, y) = a[0]

def test(x):
	for i in range(1, m):
		(q, w) = a[i]
		if q != x and w != x:
			fst = True
			snd = True
			for j in range(i + 1, m):
				if x in a[j]:
					continue
				if q not in a[j]:
					fst = False
				if w not in a[j]:
					snd = False
				if not fst and (not snd):
					return False
			return True
	return True
if test(x) or test(y):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
if m <= 2:
	print('YES')
	exit(0)
a = list({frozenset(map(int, input().split())) for q in range(m)})
x = list(a[0])[0]
y = list(a[0] - {x})[0]
s = set()
for q in a:
	if x not in q:
		s.add(q)
if len(s) < 2:
	print('YES')
	exit(0)
s = iter(s)
x = set(next(s)) & next(s)
if len(x) != 0:
	x = list(x)[0]
	for q in s:
		if x not in q:
			break
	else:
		print('YES')
		exit(0)
s = set()
for q in a:
	if y not in q:
		s.add(q)
if len(s) < 2:
	print('YES')
	exit(0)
s = iter(s)
y = set(next(s)) & next(s)
if len(y) == 0:
	print('NO')
	exit(0)
y = list(y)[0]
for q in s:
	if y not in q:
		print('NO')
		break
else:
	print('YES')


def check(x, res, m):
	find_y_from = 0
	for i in range(1, m):
		if res[i][0] != x:
			if res[i][1] != x:
				find_y_from = i
				break
	if find_y_from == 0:
		print('YES')
		return 1
	else:
		y_0 = True
		y_1 = True
		y = res[find_y_from][0]
		for i in range(find_y_from, m):
			if y != res[i][0] and x != res[i][0]:
				if y != res[i][1] and x != res[i][1]:
					y_0 = False
					break
		if y_0 == False:
			y = res[find_y_from][1]
			for i in range(find_y_from, m):
				if y != res[i][0] and x != res[i][0]:
					if y != res[i][1] and x != res[i][1]:
						y_1 = False
						break
		else:
			print('YES')
			return 1
		if y_1 == True:
			print('YES')
			return 1
	return 0
(n, m) = map(int, input().split())
res = []
for i in range(m):
	(a, b) = map(int, input().split())
	res.append((a, b))
x = res[0][0]
if check(x, res, m) != 1:
	x = res[0][1]
	if check(x, res, m) != 1:
		print('NO')


(n, m) = map(int, input().split())
s1 = set(list(range(1, n + 1)))
s2 = set(list(range(1, n + 1)))
t = []
cs = 0
for _ in range(m):
	(u, v) = map(int, input().split())
	if not t:
		t = [u, v]
	else:
		if t[0] in [u, v] and t[1] in [u, v]:
			cs += 1
		if t[0] not in [u, v]:
			s1 &= set([u, v])
		if t[1] not in [u, v]:
			s2 &= set([u, v])
if s1 or s2:
	print('YES')
else:
	print('NO')


(n, m) = input().split(sep=' ')
n = int(n)
m = int(m)
a = []
b = []
for i in range(m):
	(ai, bi) = input().split(sep=' ')
	a.append(int(ai))
	b.append(int(bi))
for x in [a[0], b[0]]:
	not_ok = False
	sel_couple = {x}
	j = 0
	for i in range(1, m):
		if not a[i] in sel_couple and (not b[i] in sel_couple):
			j = i
			not_ok = True
			break
	if j == 0:
		break
	for y in [a[j], b[j]]:
		not_ok = False
		sel_couple = {x, y}
		for i in range(1, m):
			if not a[i] in sel_couple and (not b[i] in sel_couple):
				sel_couple = set()
				not_ok = True
				break
		if not_ok == False:
			break
	if not_ok == False:
		break
if len(sel_couple) == 0:
	print('NO')
else:
	print('YES')


(n, m) = input().split(' ')
n = int(n)
m = int(m)
lala = {}
first = []
second = []
(x, y) = input().split(' ')
(x, y) = (int(x), int(y))
lala[0] = set([x, y])
first.append(x not in lala[0])
second.append(y not in lala[0])
for i in range(1, m):
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))
	lala[i] = set([a, b])
	first.append(x not in lala[i])
	second.append(y not in lala[i])
s = set(list(range(1, n + 1)))
for i in range(m):
	if first[i]:
		s &= lala[i]
if s == set():
	k = set(list(range(1, n + 1)))
	for i in range(m):
		if second[i]:
			k &= lala[i]
	if k == set():
		print('NO\n')
	else:
		print('YES\n')
else:
	print('YES\n')


(n, m) = list(map(int, input().split()))
(a, b) = list(map(int, input().split()))
ar1 = [a]
ar2 = [b]
lst = [[a, b]]
for i in range(m - 1):
	lst.append(list(map(int, input().split())))
ar3 = [0, 0]
ar4 = [0, 0]
for (a, b) in lst:
	if len(ar1) == len(ar2) == 2:
		break
	if len(ar1) != 2 and a not in ar1 and (b not in ar1):
		ar1.append(a)
		ar3 = [ar1[0], b]
	if len(ar2) != 2 and a not in ar2 and (b not in ar2):
		ar2.append(a)
		ar4 = [ar2[0], b]
ans = 'NO'
(flag1, flag2, flag3, flag4) = (0, 0, 0, 0)
for (a, b) in lst:
	if a not in ar1 and b not in ar1:
		flag1 = 1
	if a not in ar2 and b not in ar2:
		flag2 = 1
	if a not in ar3 and b not in ar3:
		flag3 = 1
	if a not in ar4 and b not in ar4:
		flag4 = 1
if flag1 == 0 or flag2 == 0 or flag3 == 0 or (flag4 == 0):
	ans = 'YES'
print(ans)


(n, m) = map(int, input().split())
A = []
for i in range(m):
	A.append(set(map(int, input().split())))
for x in A[0]:
	unused = set(range(1, n + 1))
	for pair in A[1:]:
		if x not in pair:
			unused.intersection_update(set(pair))
	if len(unused) != 0:
		print('YES')
		exit(0)
print('NO')


(n, m) = input().split()
m = int(m)
num_fre = {}
num = []
num_set = {}
pair_fre = {}
if m == 1:
	print('YES')
else:
	for _ in range(m):
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		if a not in num_fre:
			num_fre[a] = 0
			num.append(a)
		if b not in num_fre:
			num.append(b)
			num_fre[b] = 0
		p = tuple(sorted([a, b]))
		if p not in pair_fre:
			pair_fre[p] = 0
		pair_fre[p] += 1
		num_fre[a] += 1
		num_fre[b] += 1
	num.sort(reverse=True, key=lambda x: num_fre[x])
	if num_fre[num[0]] < m // 2:
		valid = False
	else:
		for i in range(len(num)):
			cur = num_fre[num[i]]
			valid = False
			for j in range(i + 1, len(num)):
				tmp = num_fre[num[j]]
				if cur + tmp < m:
					break
				if cur + tmp >= m:
					p = tuple(sorted([num[i], num[j]]))
					common = 0
					if p in pair_fre:
						common = pair_fre[p]
					t = cur + tmp - common
					if t == m:
						valid = True
				if valid == True:
					break
			if valid == True:
				break
	if valid == True:
		print('YES')
	else:
		print('NO')


(n, m) = [int(x) for x in input().split()]
firstPair = [int(x) for x in input().split()]
(arrNotX, arrNotY) = ([0] * (n + 1), [0] * (n + 1))
(countX, countY) = (1, 1)
for i in range(1, m):
	(x, y) = [int(x) for x in input().split()]
	if x != firstPair[0] and y != firstPair[0]:
		arrNotX[x] += 1
		arrNotX[y] += 1
	else:
		countX += 1
	if x != firstPair[1] and y != firstPair[1]:
		arrNotY[x] += 1
		arrNotY[y] += 1
	else:
		countY += 1
print('yes' if max(arrNotX) + countX == m or max(arrNotY) + countY == m else 'no')


(n, m) = tuple(map(int, input().split()))
x = []
for i in range(m):
	pair = tuple(map(int, input().split()))
	x.append(pair)
if m == 1:
	print('YES')
	exit(0)
s = None
top = x[0][0]
for i in range(1, m):
	if x[i][0] != top and x[i][1] != top:
		if s is None:
			s = set(x[i])
		else:
			s &= set(x[i])
if s is None or len(s) != 0:
	print('YES')
	exit(0)
s = None
top = x[0][1]
for i in range(1, m):
	if x[i][0] != top and x[i][1] != top:
		if s is None:
			s = set(x[i])
		else:
			s &= set(x[i])
if s is None or len(s) != 0:
	print('YES')
	exit(0)
print('NO')


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
from functools import lru_cache

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, m) = ilele()
A = []
for i in range(m):
	(a, b) = ilele()
	A.append((a, b))

def fun(x):
	(y1, y2) = (-1, -1)
	(f1, f2) = (1, 1)
	for i in range(1, m):
		x1 = A[i][0]
		x2 = A[i][1]
		if x1 != x and x2 != x:
			if y1 == -1:
				y1 = x1
				y2 = x2
			else:
				if x1 != y1 and x2 != y1:
					f1 = 0
				if x1 != y2 and x2 != y2:
					f2 = 0
	return f1 or f2
Y(fun(A[0][0]) or fun(A[0][1]))


(n, m) = map(int, input().split())
a = []
b = []
y = -1
for i in range(m):
	a.append(list(map(int, input().split())))
	b.append(set(a[-1]))
	if i >= 1 and y == -1:
		if not b[0] & b[-1]:
			y = i
if m <= 2 or y == -1:
	print('YES')
else:
	(c, d, e, f) = (*a[0], *a[y])
	x = [{c, e}, {c, f}, {d, e}, {d, f}]
	z = [True, True, True, True]
	for pair in b:
		for zp in [0, 1, 2, 3]:
			z[zp] = z[zp] if pair & x[zp] else False
	if z[0] or z[1] or z[2] or z[3]:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
dic = {}
pairs = []
outputy = 0
for i in range(m):
	lis2 = list(map(int, input().split()))
	pairs.append(lis2)
for i in range(2):
	x = pairs[0][i]
	dic[x] = 1
	for j in range(1, m):
		if x in pairs[j]:
			dic[x] += 1
		else:
			dic[pairs[j][0]] = dic.get(pairs[j][0], 0) + 1
			dic[pairs[j][1]] = dic.get(pairs[j][1], 0) + 1
	if dic[x] == m:
		print('YES')
		break
	for (y, value) in dic.items():
		if value == m - dic[x] and y != x:
			outputy = y
			break
	if outputy != 0:
		print('YES')
		break
	dic = {}
else:
	print('NO')


def checkCommon(tuple1, tuple2):
	temp = set()
	temp.add(tuple1[0])
	temp.add(tuple1[1])
	temp.add(tuple2[0])
	temp.add(tuple2[1])
	if len(temp) == 4:
		return False
	else:
		return True

def main():
	[n, m] = list(map(int, input().split()))
	ar = list()
	for i in range(m):
		pair = tuple(map(int, input().split()))
		ar.append(pair)
	first = ar[0]
	flag = 0
	for i in range(1, m):
		second = ar[i]
		if checkCommon(first, second) == False:
			flag = 1
			x = [first[0], first[1]]
			y = [second[0], second[1]]
			break
	if flag == 0:
		print('YES')
	else:
		for i in x:
			for j in y:
				flag = 0
				for k in range(m):
					if i not in ar[k] and j not in ar[k]:
						flag = 1
				if flag == 0:
					print('YES')
					return
		print('NO')
main()


(n, m) = map(int, input().split())
d = {}
p = []
for i in range(m):
	(x, y) = map(int, input().split())
	if x == y:
		d[x] = d.get(x, 0) + 1
	else:
		d[x] = d.get(x, 0) + 1
		d[y] = d.get(y, 0) + 1
	p.append([x, y])
xx = []
x = 0
for i in d:
	if d[i] >= m / 2:
		xx.append(i)
if len(xx) == 0:
	print('NO')
	exit()
y = 0
for x in xx:
	p1 = []
	for i in p:
		if i[0] != x and i[1] != x:
			p1.append(i)
	d1 = {}
	for i in p1:
		if i[0] == i[1]:
			d1[i[0]] = d1.get(i[0], 0) + 1
		else:
			d1[i[0]] = d1.get(i[0], 0) + 1
			d1[i[1]] = d1.get(i[1], 0) + 1
	if len(d1) == 0 or max(d1.values()) == len(p1):
		y += 1
if y != 0:
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, m) = list(map(int, input().split()))
freq = [0 for i in range(n + 1)]
arr = []
f = 0
for i in range(m):
	(u, v) = list(map(int, input().split()))
	if f == 0:
		temp = [u, v]
		f = 1
	p = [u, v]
	p = set(p)
	arr.append(p)
for i in temp:
	ans = []
	for j in arr:
		x = list(j)
		if i in x:
			continue
		else:
			ans.append(j)
	if ans == []:
		print('YES')
		exit()
	else:
		x = ans[0]
		f = 0
		for j in range(1, len(ans)):
			y = ans[j]
			x = x.intersection(y)
			if x == set():
				f = 1
				break
		if f == 0:
			print('YES')
			exit()
print('NO')


(n, m) = [int(i) for i in input().split()]
l = []
for i in range(m):
	l.append([int(i) - 1 for i in input().split()])
for i in range(2):
	val = [0 for i in range(n)]
	a = l[0][i]
	alx = 0
	for x in range(m):
		if l[x][0] != a and l[x][1] != a:
			val[l[x][0]] += 1
			val[l[x][1]] += 1
			alx += 1
	maxx = -1
	for y in range(n):
		maxx = max(maxx, val[y])
	if alx == maxx:
		print('YES')
		break
	elif i == 1:
		print('NO')


(a, b) = map(int, input().split())
(q, w) = map(int, input().split())
x1 = q
k1 = True
k2 = True
x2 = w
A1 = []
A2 = []
for i in range(b - 1):
	B = list(map(int, input().split()))
	if x1 not in set(B):
		if len(A1) != 0 and k1 == True:
			A1 = list(set(A1) & set(B))
			if len(A1) == 0:
				k1 = False
		elif k1 == True:
			A1 = B[:]
	if x2 not in set(B):
		if len(A2) != 0 and k2 == True:
			A2 = list(set(A2) & set(B))
			if len(A2) == 0:
				k2 = False
		elif k2 == True:
			A2 = B[:]
if k1 == True or k2 == True:
	print('YES')
else:
	print('NO')


from sys import stdin, setrecursionlimit
import heapq

def get_count(num, old_flag):
	flag = [0] * len(pairs)
	count = 0
	for i in range(len(pairs)):
		if num in pairs[i] and old_flag[i] == 0:
			flag[i] = 1
			count += 1
	return (count, flag)

def no_interest(num, flag):
	for i in range(len(pairs)):
		if num not in pairs[i] and flag[i] == 0:
			return i
	return -1
setrecursionlimit(15000)
(n, m) = list(map(int, stdin.readline().split()))
pairs = []
for _ in range(m):
	pairs.append(list(map(int, stdin.readline().split())))
flag = [0] * m
(c1, flag) = get_count(pairs[0][0], flag)
index = no_interest(pairs[0][0], flag)
if index == -1:
	print('YES')
	exit()
(c2, flag2) = get_count(pairs[index][0], flag)
(c3, flag2) = get_count(pairs[index][1], flag)
if c1 + c2 == m or c1 + c3 >= m:
	print('YES')
else:
	flag = [0] * m
	(c1, flag) = get_count(pairs[0][1], flag)
	index = no_interest(pairs[0][1], flag)
	if index == -1:
		print('YES')
		exit()
	(c2, flag2) = get_count(pairs[index][0], flag)
	(c3, flag2) = get_count(pairs[index][1], flag)
	if c1 + c2 == m or c1 + c3 == m:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
pair = [-1 for i in range(m)]
i = 0
while i < m:
	pair[i] = list(map(int, input().split()))
	i += 1
x = pair[0]
for i in x:
	cnt = [0 for i in range(n + 1)]
	cnter = 0
	for j in pair:
		if j[0] != i and j[1] != i:
			cnt[j[0]] += 1
			cnt[j[1]] += 1
			cnter += 1
	if max(cnt) == cnter:
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(m):
	a.append(list(map(int, input().split())))
x = a[0][0]
y = a[0][1]
d = {}
f = 0
c = 0
for i in range(1, m):
	if a[i][0] != x and a[i][1] != x:
		if d.get(a[i][0], 0) == c:
			d[a[i][0]] = d.get(a[i][0], 0) + 1
		if d.get(a[i][1], 0) == c:
			d[a[i][1]] = d.get(a[i][1], 0) + 1
		if d.get(a[i][0], 0) != c + 1 and d.get(a[i][1], 0) != c + 1:
			f = 1
			break
		c += 1
d1 = {}
c = 0
if f == 0:
	exit(print('YES'))
if f == 1:
	for i in range(1, m):
		if a[i][0] != y and a[i][1] != y:
			if d1.get(a[i][0], 0) == c:
				d1[a[i][0]] = d1.get(a[i][0], 0) + 1
			if d1.get(a[i][1], 0) == c:
				d1[a[i][1]] = d1.get(a[i][1], 0) + 1
			if d1.get(a[i][0], 0) != c + 1 and d1.get(a[i][1], 0) != c + 1:
				f = 2
				break
			c += 1
if f == 1:
	exit(print('YES'))
exit(print('NO'))
print(d, d1, f)
if f == 0:
	print('YES')
else:
	print('NO')


def solve(max_number, count):
	pairs = [[0, 0] for _ in range(count)]
	for i in range(count):
		(a, b) = map(int, input().split())
		pairs[i][0] = a
		pairs[i][1] = b
	(x, y) = pairs[0]
	for v in (x, y):
		counts = [0] * (max_number + 1)
		alls = 0
		for (p1, p2) in pairs:
			if p1 != v and p2 != v:
				counts[p1] += 1
				counts[p2] += 1
				alls += 1
		if max(counts) == alls:
			return 'YES'
	return 'NO'
(n, m) = map(int, input().split())
s = solve(n, m)
print(s)


(n, m) = [int(i) for i in input().split()]
lst = list()
for j in range(m):
	(x, y) = [int(z) for z in input().split()]
	lst.append([x, y])
count = 0
pair = lst[0]
for v in pair:
	a = [0] * (n + 1)
	count = 0
	for elem in lst:
		if elem[0] != v and elem[1] != v:
			a[elem[0]] = a[elem[0]] + 1
			a[elem[1]] = a[elem[1]] + 1
			count += 1
	if count in a:
		print('YES')
		quit()
print('NO')


from copy import copy
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
(n, m) = li()
a = []
for i in range(m):
	a.append(li())
s = set(range(1, n + 1))
for x in (a[0][0], a[0][1]):
	s1 = copy(s)
	for i in range(1, m):
		(p, q) = a[i]
		if x != p and x != q:
			s1.intersection_update({p, q})
	if len(s1):
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
pairs = [tuple((int(x) for x in input().split())) for _ in range(m)]
possible = {pairs[0], (pairs[0][0], None), (pairs[0][1], None)}
for p in pairs[1:]:
	add = set()
	remove = set()
	for o in possible:
		if p[0] in o or p[1] in o:
			continue
		remove.add(o)
		if o[1] is None:
			add.add((o[0], p[0]))
			add.add((o[0], p[1]))
	possible = possible - remove | add
	if not possible:
		break
if not possible:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split()))
p = set()
for i in range(m):
	p.add(tuple(map(int, input().split())))
if len(p) == 1:
	print('YES')
	exit(0)
(x, y) = p.pop()
notx = []
noty = []
for (a, b) in p:
	if x not in (a, b):
		notx.append(set([a, b]))
	if y not in (a, b):
		noty.append(set([a, b]))
(inotx, inoty) = (False, False)
if notx:
	inotx = set.intersection(*notx)
if noty:
	inoty = set.intersection(*noty)
if inotx or inoty:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from collections import defaultdict
import math

def input():
	return stdin.readline().strip()
(n, m) = map(int, input().split())
ans = []
for i in range(m):
	(a, b) = map(int, input().split())
	ans.append([a, b])
tri = [ans[0][0], ans[0][1]]
flag = False
for ele in tri:
	count = 0
	dct = defaultdict(int)
	for j in range(1, m):
		if ans[j][0] != ele and ans[j][1] != ele:
			count += 1
			dct[ans[j][0]] += 1
			dct[ans[j][1]] += 1
	if len(dct) == 0 or max(dct.values()) == count:
		flag = True
		break
if flag:
	print('Yes')
else:
	print('No')


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
d = []
for i in range(m):
	d.append(list(map(int, input().split())))
x = d[0][0]
y = d[0][1]
c = []
e = []
g = []
for i in d:
	if x in i:
		c.append(i)
	if y in i:
		e.append(i)
	if x not in i and y not in i:
		g.append(i)
if len(g) == 0:
	exit(print('YES'))
s = set(g[0])
for i in g:
	s = s.intersection(set(i))
if len(s) == 0:
	exit(print('NO'))
k = list(s)
for s in k:
	fl1 = fl2 = 1
	for i in c:
		if s not in i and y not in i:
			fl1 = 0
			break
	for i in e:
		if s not in i and x not in i:
			fl2 = 0
			break
	if fl1 or fl2:
		exit(print('YES'))
print('NO')


import sys
(N, M) = map(int, input().split())
P = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
idx = P[0][0]
S = set()
for (i, (a, b)) in enumerate(P):
	if a == idx or b == idx:
		continue
	break
else:
	print('YES')
	return
S = set([P[i][0], P[i][1]])
for (a, b) in P[i:]:
	if a == idx or b == idx:
		continue
	S.intersection_update(set([a, b]))
	if not S:
		break
else:
	print('YES')
	return
idx = P[0][1]
S = set()
for (i, (a, b)) in enumerate(P):
	if a == idx or b == idx:
		continue
	break
else:
	print('YES')
	return
S = set([P[i][0], P[i][1]])
for (a, b) in P[i:]:
	if a == idx or b == idx:
		continue
	S.intersection_update(set([a, b]))
	if not S:
		break
else:
	print('YES')
	return
print('NO')


from sys import stdin, stdout
import math, bisect
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	(n, m) = M()
	a = []
	for i in range(m):
		(x, y) = M()
		a += [(x, y)]
	for i in a[0]:
		c = 0
		b = [0] * (n + 1)
		for j in a:
			if j[0] != i and j[1] != i:
				b[j[0]] += 1
				b[j[1]] += 1
				c += 1
		if max(b) == c:
			print('YES')
			return
	print('NO')
for _ in range(1):
	solve()


a = [int(i) for i in input().split()]
n = a[0]
m = a[1]
arr = [0 for i in range(n)]
maxa1 = 0
maxa2 = 0
inputa = []
for i in range(m):
	x = [int(i) for i in input().split()]
	x[0] -= 1
	x[1] -= 1
	inputa.append(x)
	arr[x[0]] += 1
	arr[x[1]] += 1
ans = []
for i in range(n):
	if arr[i] >= m // 2:
		ans.append(i)
val1 = -1
val2 = -1
flag = 0
for i in ans:
	count = 0
	freq = [0 for k in range(n)]
	val1 = i
	for j in inputa:
		if j[0] == i or j[1] == i:
			count += 1
		else:
			freq[j[0]] += 1
			freq[j[1]] += 1
	for k in range(n):
		if freq[k] == m - count:
			val2 = k
			flag = 1
			break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
my_sets = {}
(no_find, no_find1) = (False, False)
(a, b) = map(int, input().split())
val = [a, b]
my_sets.update({a: [b]})
my_sets.update({b: [a]})
for i in range(1, m):
	(x, y) = map(int, input().split())
	if x not in my_sets.keys():
		my_sets.update({x: [y]})
	else:
		my_sets[x].append(y)
	if y not in my_sets.keys():
		my_sets.update({y: [x]})
	else:
		my_sets[y].append(x)
for v in val:
	remain = m - len(my_sets[v])
	for k in my_sets.keys():
		if k != v:
			intrim = list(filter(lambda x: x != v, my_sets[k]))
			if len(intrim) == remain:
				print('Yes')
				exit()
print('No')


(n, m) = map(int, input().split())
nums_list = []
for i in range(m):
	(n1, n2) = map(int, input().split())
	nums_list.append([n1, n2])
flag = True
outerloopflag = False
for i in nums_list[0]:
	j = 1
	while j < m and i in nums_list[j]:
		j += 1
	if j == m:
		print('YES')
		flag = False
		break
	else:
		for x in nums_list[j]:
			k = j + 1
			while k < m and (x in nums_list[k] or i in nums_list[k]):
				k += 1
			if k == m:
				print('YES')
				flag = False
				outerloopflag = True
				break
			elif k < m and i in nums_list[k]:
				k += 1
	if outerloopflag:
		break
if flag:
	print('NO')


s = input()
(n, m) = map(int, s.split(' '))
lst = []
for i in range(m):
	s = input()
	(a, b) = map(int, s.split(' '))
	lst.append([a, b])
p = 0
varx = lst[0]
for v in varx:
	xy_list = [0] * (n + 1)
	p = 0
	for item in lst:
		if item[0] != v and item[1] != v:
			xy_list[item[0]] = xy_list[item[0]] + 1
			xy_list[item[1]] = xy_list[item[1]] + 1
			p += 1
	if p in xy_list:
		print('YES')
		quit()
print('NO')


(n, m) = map(int, input().split())
a = [[*map(int, input().split())] for _ in range(m)]

def g():
	for z in range(2):
		x = a[0][z]
		for i in range(m):
			if x not in a[i]:
				break
		else:
			return 0
		for w in range(2):
			y = a[i][w]
			for j in range(m):
				if x not in a[j] and y not in a[j]:
					break
			else:
				return 0
	return 1
print('YNEOS'[g()::2])


import sys
from collections import defaultdict
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))

def checkAns(x1, pairs):
	ans = False
	allPssed = True
	for i in range(len(pairs)):
		if x1 not in pairs[i]:
			allPssed = False
			break
	if allPssed:
		ans = True
	return ans
(n, m) = intInp()
ans = False
pairs = []
for i in range(m):
	pairs.append(intInp())
x = pairs[0][0]
pairsWithoutX = []
for i in range(m):
	if x not in pairs[i]:
		pairsWithoutX.append(pairs[i])
if len(pairsWithoutX) > 0:
	x1 = pairsWithoutX[0][0]
	y1 = pairsWithoutX[0][1]
if len(pairsWithoutX) == 0 or checkAns(x1, pairsWithoutX) or checkAns(y1, pairsWithoutX):
	print('Yes')
else:
	y = pairs[0][1]
	pairsWithoutY = []
	for i in range(m):
		if y not in pairs[i]:
			pairsWithoutY.append(pairs[i])
	if len(pairsWithoutY) > 0:
		x1 = pairsWithoutY[0][0]
		y1 = pairsWithoutY[0][1]
	if len(pairsWithoutY) == 0 or checkAns(x1, pairsWithoutY) or checkAns(y1, pairsWithoutY):
		print('Yes')
	else:
		print('No')


from sys import stdin
(n, m) = map(int, stdin.readline().split())
edges = []
for i in range(m):
	(a, b) = map(int, stdin.readline().split())
	edges.append((a, b))
pin = edges[0][0]
pinn = edges[0][1]
fedges = list(filter(lambda x: pin not in x, edges))
fedgess = list(filter(lambda x: pinn not in x, edges))
if len(fedges) == 0 or len(fedgess) == 0:
	print('YES')
else:
	pin1 = fedges[0][0]
	pin2 = fedges[0][1]
	pin11 = fedgess[0][0]
	pin22 = fedgess[0][1]
	p1edges = list(filter(lambda x: pin1 not in x, fedges))
	p2edges = list(filter(lambda x: pin2 not in x, fedges))
	xdges = list(filter(lambda x: pin11 not in x, fedgess))
	xdgess = list(filter(lambda x: pin22 not in x, fedgess))
	if len(p1edges) == 0 or len(p2edges) == 0 or len(xdges) == 0 or (len(xdgess) == 0):
		print('YES')
	else:
		print('NO')


t = 1
for test in range(t):
	ans = 'NO'
	(n, m) = list(map(int, input().split()))
	arr = []
	for i in range(m):
		(a, b) = list(map(int, input().split()))
		tmp = [a, b]
		arr.append(tmp)
	x = arr[0][0]
	y = [i for i in range(n + 1)]
	y = set(y)
	for pair in arr:
		if x not in pair:
			y = y.intersection(set(pair))
	if len(y) > 0:
		ans = 'YES'
	x = arr[0][1]
	y = [i for i in range(n + 1)]
	y = set(y)
	for pair in arr:
		if x not in pair:
			y = y.intersection(set(pair))
	if len(y) > 0:
		ans = 'YES'
	print(ans)


(n, m) = [int(x) for x in input().split()]
all_pairs = []
for i in range(m):
	p = [int(x) for x in input().split()]
	all_pairs.append(p)
ok = False
for x in p:
	candidate = None
	for e in all_pairs:
		if e[0] != x and e[1] != x:
			candidate = e
			break
	if candidate == None:
		ok = True
		break
	else:
		c1 = True
		c2 = True
		for e in all_pairs:
			if e[0] != x and e[0] != candidate[0] and (e[1] != x) and (e[1] != candidate[0]):
				c1 = False
				if c2 == False:
					break
			if e[0] != x and e[0] != candidate[1] and (e[1] != x) and (e[1] != candidate[1]):
				c2 = False
				if c1 == False:
					break
		if c1 == True or c2 == True:
			ok = True
			break
if ok:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
lst = [list(map(int, input().split())) for x in range(m)]
possible = False
first = set(lst[0])
for i in first:
	_other = []
	for j in lst[1:]:
		if i not in j:
			_other += [j]
	if _other:
		k = set(_other[0])
		for l in _other[1:]:
			k &= set(l)
		if k and i != k.pop():
			possible = True
			break
	else:
		possible = True
		break
if possible:
	print('YES')
else:
	print('NO')


def check(a, b, d, m):
	f = a in d[b]
	if f:
		return len(d[a]) + len(d[b]) - 1 == m
	return len(d[a]) + len(d[b]) == m
from collections import Counter

def solve():
	(n, m) = map(int, input().split())
	d = {i + 1: [] for i in range(n)}
	tots = []
	realm = 0
	visited = set()
	for i in range(m):
		(u, v) = map(int, input().split())
		if (u, v) in visited or (v, u) in visited:
			continue
		d[u].append(v)
		d[v].append(u)
		tots.append(u)
		tots.append(v)
		realm += 1
		visited.add((u, v))
	m = realm
	cnt = Counter(tots)
	mlist = [(k, v) for (k, v) in cnt.items()]
	mlist.sort(key=lambda x: x[1], reverse=True)
	mx = mlist[0][1]
	flag = False
	l = len(mlist)
	for i in range(l):
		(k1, v1) = mlist[i]
		if cnt[k1] + mx < m:
			break
		for j in range(i + 1, l):
			(k2, v2) = mlist[j]
			if cnt[k2] + cnt[k1] < m:
				break
			elif check(k1, k2, d, m):
				flag = True
				break
	if flag:
		print('YES')
	else:
		print('NO')
	del d
solve()


def check_valid(ls, x, y):
	for p in ls:
		if p[0] != x and p[0] != y and (p[1] != x) and (p[1] != y):
			return False
	return True

def find_pair(ls):
	for x in ls[0]:
		if check_valid(ls, x, -1):
			return True
		for i in range(1, m):
			if ls[i][0] != x and ls[i][1] != x:
				if check_valid(ls, x, ls[i][0]) or check_valid(ls, x, ls[i][1]):
					return True
				break
	return False
(n, m) = map(int, input().split())
ls = []
for _ in range(m):
	(a, b) = map(int, input().split())
	ls.append([a, b])
if find_pair(ls):
	print('YES')
else:
	print('NO')


from math import *

def sol():
	(n, m) = [int(x) for x in input().split()]
	arr = [0] * n
	rep = dict()
	for i in range(m):
		(a, b) = [int(x) for x in input().split()]
		arr[a - 1] += 1
		arr[b - 1] += 1
		if (a, b) in rep:
			rep[a, b] += 1
		else:
			rep[a, b] = 1
	candidates = []
	for i in range(1, n + 1):
		if arr[i - 1] >= m / 2:
			candidates += [i]
	for i in candidates:
		for j in range(1, n + 1):
			if i == j:
				continue
			x = arr[i - 1]
			y = arr[j - 1]
			intersect = rep.get((i, j), 0) + rep.get((j, i), 0)
			if x + y - intersect >= m:
				return 'YES'
	return 'NO'
print(sol())


import sys
input = sys.stdin.readline

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

def mi():
	return map(int, input().rstrip().split())

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

def li():
	return list(input().rstrip())
(n, m) = mi()
l = [0] * m
r = [0] * m
for i in range(m):
	(l[i], r[i]) = mi()
lf = l[0]
rf = r[0]
flag = True
for i in range(m):
	if l[i] != lf and r[i] != lf:
		if l[i] != rf and r[i] != rf:
			lf2 = l[i]
			rf2 = r[i]
			flag = False
			break
if flag:
	print('YES')
	sys.exit()
Lis = [lf, rf, lf2, rf2]
for i in range(3):
	for j in range(i + 1, 4):
		left = Lis[i]
		right = Lis[j]
		for cnt in range(m):
			if l[cnt] != left and r[cnt] != left:
				if l[cnt] != right and r[cnt] != right:
					break
		else:
			print('YES')
			sys.exit()
print('NO')


(n, m) = list(map(int, input().split()))
arr = []
for i in range(0, m):
	(a, b) = list(map(int, input().split()))
	arr.append([a, b])
x1 = arr[0][0]
x2 = arr[0][1]
y1 = 0
y2 = 0
for i in range(0, m):
	if x1 in arr[i] or x2 in arr[i]:
		skb = 1
	else:
		y1 = arr[i][0]
		y2 = arr[i][1]
		break
	if i == m - 1:
		y1 = arr[i][0]
		y2 = arr[i][1]
flag = 0
for i in range(0, m):
	if x1 not in arr[i] and y1 not in arr[i]:
		break
	if i == m - 1:
		flag = 1
for i in range(0, m):
	if x1 not in arr[i] and y2 not in arr[i]:
		break
	if i == m - 1:
		flag = 1
for i in range(0, m):
	if x2 not in arr[i] and y1 not in arr[i]:
		break
	if i == m - 1:
		flag = 1
for i in range(0, m):
	if x2 not in arr[i] and y2 not in arr[i]:
		break
	if i == m - 1:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
(n, m) = map(int, input().split())
total = [False for _ in range(m)]
for i in range(m):
	total[i] = tuple(input().split())
k = True
idx = 0
for test_case in [[total[i][0]], [total[i][1]]]:
	test_filled = False
	idx = 0
	second = ''
	for i in range(m):
		for item in test_case:
			if item in total[i]:
				break
		else:
			if not test_filled:
				test_case.append(total[i][0])
				second = total[i][1]
				test_filled = True
			else:
				break
	else:
		print('YES')
		exit()
	test_case[1] = second
	for i in range(idx, m):
		for item in test_case:
			if item in total[i]:
				break
		else:
			break
	else:
		print('YES')
		exit()
else:
	print('NO')


(n, m) = map(int, input().split())
pairs = []
for _ in range(m):
	(x, y) = map(int, input().split())
	pairs.append((x, y))
for first in (pairs[0][0], pairs[0][1]):
	val = [0] * n
	all = 0
	for pair in pairs:
		if pair[0] != first and pair[1] != first:
			val[pair[0] - 1] += 1
			val[pair[1] - 1] += 1
			all += 1
	if max(val) == all:
		print('YES')
		exit()
print('NO')
exit()


from sys import stdin

def input():
	return stdin.readline().strip()
from itertools import permutations, combinations
(m, n) = map(int, input().split())
pairs = []
for i in range(n):
	(a, b) = map(int, input().split())
	pairs.append((a, b))
if n == 1:
	print('YES')
else:
	possible = set([pairs[0][0], pairs[0][1]])
	flag = True
	for i in range(n):
		if pairs[i][0] in possible or pairs[i][1] in possible:
			continue
		elif len(possible) == 4:
			flag = False
			break
		else:
			possible.add(pairs[i][0])
			possible.add(pairs[i][1])
	if flag:
		possible = list(possible)
		x_y = list(combinations(possible, 2))
		for (x, y) in x_y:
			x_y_ = set([x, y])
			flag = True
			for i in range(n):
				if pairs[i][0] in x_y_ or pairs[i][1] in x_y_:
					continue
				else:
					flag = False
					break
			if flag:
				break
	if flag:
		print('YES')
	else:
		print('NO')


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)
(n, m) = read_int_list()
input_lists = []
for _ in range(m):
	input_lists.append(sorted(read_int_list()))
if m <= 2:
	print('YES')
	sys.exit()
freqs = [0 for _ in range(n + 1)]
first = input_lists[0][0]
for i in range(m):
	if first in input_lists[i]:
		freqs[first] += 1
	else:
		freqs[input_lists[i][0]] += 1
		freqs[input_lists[i][1]] += 1
for i in range(1, n):
	if i != first and freqs[i] + freqs[first] == m:
		print('YES')
		sys.exit()
freqs = [0 for _ in range(n + 1)]
first = input_lists[0][1]
for i in range(m):
	if first in input_lists[i]:
		freqs[first] += 1
	else:
		freqs[input_lists[i][0]] += 1
		freqs[input_lists[i][1]] += 1
for i in range(1, n):
	if i != first and freqs[i] + freqs[first] == m:
		print('YES')
		sys.exit()
print('NO')


arr = input()
(N, M) = [int(x) for x in arr.split(' ')]
data = [[0] * 2 for _ in range(M)]
for i in range(M):
	arr = input()
	(A, B) = [int(x) for x in arr.split(' ')]
	data[i][0] = A
	data[i][1] = B
pair = [[0, 0], [0, 0], [0, 0], [0, 0]]
k = 0
for x in data[0]:
	for i in range(M):
		if x not in data[i]:
			pair[k][0] = x
			pair[k][1] = data[i][0]
			k += 1
			pair[k][0] = x
			pair[k][1] = data[i][1]
			k += 1
			break
for p in pair:
	A = p[0]
	B = p[1]
	flag = 0
	if A != 0 and B != 0:
		for i in range(M):
			if A not in data[i] and B not in data[i]:
				flag = 1
				break
	if flag == 0:
		print('YES')
		break
if flag == 1:
	print('NO')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(a, b) = ([None for _ in range(m)], [None for _ in range(m)])
for i in range(m):
	(a[i], b[i]) = map(int, input().split())
(f, c) = ([0 for _ in range(n + 100)], 0)
for i in range(m):
	if a[i] != a[0] and b[i] != a[0]:
		c += 1
		f[a[i]] += 1
		f[b[i]] += 1
if max(f) == c:
	print('YES')
else:
	(f, c) = ([0 for _ in range(n + 100)], 0)
	for i in range(m):
		if a[i] != b[0] and b[i] != b[0]:
			c += 1
			f[a[i]] += 1
			f[b[i]] += 1
	if max(f) == c:
		print('YES')
	else:
		print('NO')


(m, n) = map(int, input().split())
ll = []
for i in range(n):
	(x, y) = map(int, input().split())
	ll.append([x, y])
l = (ll[0][0], ll[0][1])
for i in range(2):
	aa = l[i]
	ans = 0
	bib = [0] * (m + 1)
	for j in ll:
		if j[0] != aa and j[1] != aa:
			bib[j[0]] += 1
			bib[j[1]] += 1
			ans += 1
	if max(bib) == ans:
		print('YES')
		exit()
print('NO')


from collections import Counter
from itertools import chain
ab = tuple((tuple(map(int, input().split())) for _ in range(int(input().split()[[2, 1][1]]))))
for x_ in Counter(chain(*ab)).most_common(4):
	x = x_[0]
	ab2 = (abi for abi in ab if x not in abi)
	try:
		try:
			ys = set(next(ab2))
		except StopIteration:
			pass
		else:
			for abi2 in ab2:
				ys.intersection_update(abi2)
			assert ys
		print('YES')
		break
	except AssertionError:
		pass
else:
	print('NO')


(n, m) = list(map(int, input().split()))
(a, b) = list(map(int, input().split()))
ar1 = [a]
ar2 = [b]
lst = [[a, b]]
for i in range(m - 1):
	lst.append(list(map(int, input().split())))
ar3 = [0, 0]
ar4 = [0, 0]
for (a, b) in lst:
	if len(ar1) != 2 and a not in ar1 and (b not in ar1):
		ar1.append(a)
		ar3 = [ar1[0], b]
	if len(ar2) != 2 and a not in ar2 and (b not in ar2):
		ar2.append(a)
		ar4 = [ar2[0], b]
ans = 'NO'
flag = 0
for (a, b) in lst:
	if a not in ar1 and b not in ar1:
		flag = 1
		break
if flag == 0:
	ans = 'YES'
flag = 0
for (a, b) in lst:
	if a not in ar2 and b not in ar2:
		flag = 1
		break
if flag == 0:
	ans = 'YES'
flag = 0
for (a, b) in lst:
	if a not in ar3 and b not in ar3:
		flag = 1
		break
if flag == 0:
	ans = 'YES'
flag = 0
for (a, b) in lst:
	if a not in ar4 and b not in ar4:
		flag = 1
		break
if flag == 0:
	ans = 'YES'
print(ans)


(n, m) = map(int, input().split())
res = [set(map(int, input().split())) for _ in range(m)]
a = res[0]
has = False
for i in range(m):
	if not res[i] & a:
		b = res[i]
		has = True
if not has:
	print('YES')
	return
for x in a:
	for y in b:
		fail = False
		for _ in res:
			if x not in _ and y not in _:
				fail = True
		if not fail:
			print('YES')
			return
print('NO')


(n, k) = map(int, input().split())
import sys
input = sys.stdin.readline

def check2(g1):
	if len(g1) == 0:
		return True
	m1 = g1[0][0]
	flag = 0
	for i in range(1, len(g1)):
		if g1[i][0] != m1 and g1[i][1] != m1:
			flag = 1
			break
	if flag == 0:
		return True
	m1 = g1[0][1]
	flag = 0
	for i in range(1, len(g1)):
		if g1[i][0] != m1 and g1[i][1] != m1:
			flag = 1
			break
	if flag == 0:
		return True
	return False

def check(x, ans):
	g1 = []
	for i in range(len(ans)):
		if ans[i][0] == x or ans[i][1] == x:
			continue
		else:
			g1.append(ans[i])
	m = check2(g1)
	return m
ans = []
for i in range(k):
	(x, y) = map(int, input().split())
	ans.append([x, y])
if check(ans[0][0], ans) or check(ans[0][1], ans):
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, sys.stdin.readline().split())
mark = [0 for _ in range(n + 1)]
(f, s) = map(int, sys.stdin.readline().split())
score = [0, 0]
option1 = [0, 0, 0]
option2 = [0, 0, 0]
(c1, c2) = (0, 0)
both = 1
both2 = 0
start = 0
ans = 'YES'
pairs = [[f, s]]
for i in range(m - 1):
	(a, b) = map(int, sys.stdin.readline().split())
	c = [a, b]
	pairs.append(c)
	if f in c and s in c:
		both += 1
	elif f in c:
		score[0] += 1
	elif s in c:
		score[1] += 1
	else:
		(c1, c2) = (a, b)
if both + score[0] + score[1] == m:
	print('YES')
else:
	for pair in pairs:
		if c1 in pair and c2 in pair:
			both2 += 1
		elif c1 in pair:
			if f not in pair and s not in pair:
				option1[0] += 1
			elif f not in pair:
				option1[1] += 1
			elif s not in pair:
				option1[2] += 1
		elif c2 in pair:
			if f not in pair and s not in pair:
				option2[0] += 1
			elif f not in pair:
				option2[1] += 1
			elif s not in pair:
				option2[2] += 1
	op1 = both + score[0] + both2 + option1[0] + option1[1]
	op2 = both + score[1] + both2 + option1[0] + option1[2]
	op3 = both + score[0] + both2 + option2[0] + option2[1]
	op4 = both + score[1] + both2 + option2[0] + option2[2]
	check = [op1, op2, op3, op4]
	if m in check:
		print('YES')
	else:
		print('NO')


(n, m) = list(map(int, input().split()))
ms = []
cnt = {}

def cd(x):
	if x in cnt:
		cnt[x] += 1
	else:
		cnt[x] = 1
for i in range(m):
	(x, y) = list(map(int, input().split()))
	ms.append((x, y))
	cd(x)
	cd(y)
ans = []
for (k, v) in list(cnt.items()):
	if v >= m // 2:
		ans.append(k)

def check_one(c):
	for i in range(m):
		(x, y) = ms[i]
		if x == c or y == c:
			continue
		if check_two(c, x, i):
			return True
		if check_two(c, y, i):
			return True
		return False
	return True

def check_two(c1, c2, s):
	for i in range(s, m):
		(x, y) = ms[i]
		if x == c1 or x == c2 or y == c1 or (y == c2):
			continue
		else:
			return False
	return True
for a in ans:
	if check_one(a):
		print('YES')
		quit()
print('NO')


def check(x, y):
	if y is None:
		for i in a:
			if x not in i:
				return False
		return True
	for i in a:
		if x not in i and y not in i:
			return False
	return True
(n, m) = map(int, input().split())
a = [list(input().split()) for i in range(m)]
for x in a[0]:
	if check(x, None):
		print('YES')
		exit()
	for i in a:
		if x not in i:
			if check(x, i[0]) or check(x, i[1]):
				print('YES')
				exit()
			break
print('NO')


(n, m) = map(int, input().split())
pairs = [tuple(map(int, input().split())) for i in range(m)]
first = pairs[0]
(x, y) = ((), ())
all_differ = lambda x, y: x[0] != y[0] and x[1] != y[0] and (x[0] != y[1]) and (x[1] != y[1])
for p in pairs:
	if all_differ(first, p):
		(x, y) = (first, p)
		break
else:
	print('YES')
	exit(0)
for (a, b) in [(x[0], y[0]), (x[0], y[1]), (x[1], y[0]), (x[1], y[1])]:
	for p in pairs:
		if all_differ((a, b), p):
			break
	else:
		print('YES')
		exit(0)
print('NO')


p = input().rstrip().split(' ')
l = []
q = []
w = []
F = 0
for i in range(0, int(p[1])):
	u = input().rstrip().split(' ')
	D = []
	D.append(int(u[0]))
	D.append(int(u[1]))
	l.append(D)
	if i == 0:
		a = int(u[0])
		b = int(u[1])
	else:
		D = []
		D.append(int(u[0]))
		D.append(int(u[1]))
		if a not in D and b not in D:
			c = int(u[0])
			d = int(u[1])
			F = 1
if F == 0:
	print('YES')
else:
	A = 0
	B = 0
	C = 0
	D = 0
	for i in range(0, len(l)):
		if a in l[i] or c in l[i]:
			A += 1
		if a in l[i] or d in l[i]:
			B += 1
		if b in l[i] or c in l[i]:
			C += 1
		if b in l[i] or d in l[i]:
			D += 1
	if A == len(l) or B == len(l) or C == len(l) or (D == len(l)):
		print('YES')
	else:
		print('NO')


import sys
(n, m) = map(int, input().split())
(a, b) = map(int, input().split())
pool = [a, b]
pairs = [(a, b)]
for _ in range(m - 1):
	(a, b) = map(int, input().split())
	if a not in pool and b not in pool:
		pool.append(a)
		pool.append(b)
	pairs.append((a, b))
	if len(pool) >= 5:
		print('NO')
		sys.exit()
count = 0
for i in range(len(pool) - 1):
	for j in range(i + 1, len(pool)):
		x = [pool[i], pool[j]]
		for k in pairs:
			if k[0] != x[0] and k[0] != x[1] and (k[1] != x[0]) and (k[1] != x[1]):
				count += 1
				break
if count != len(pool) * (len(pool) - 1) // 2:
	print('YES')
else:
	print('NO')


inp = input().split()
n = int(inp[0])
m = int(inp[1])
pairs = []
flag = True
x = x1 = x2 = y = y1 = y2 = 0
for i in range(m):
	inp = input().split()
	pairs.append(inp)
for i in range(m):
	if i == 0:
		x = pairs[i][0]
		continue
	if x not in pairs[i] and y not in pairs[i]:
		if y1 == 0:
			y1 = pairs[i][0]
			y2 = pairs[i][1]
			continue
		elif y == 0:
			if y1 in pairs[i] and y2 in pairs[i]:
				pass
			elif y1 in pairs[i]:
				y = y1
			elif y2 in pairs[i]:
				y = y2
			else:
				flag = False
				break
		elif y not in pairs[i]:
			flag = False
			break
flag2 = True
y1 = y2 = x = y = 0
if flag == False:
	for i in range(m):
		if i == 0:
			x = pairs[i][1]
			continue
		if x not in pairs[i] and y not in pairs[i]:
			if y1 == 0:
				y1 = pairs[i][0]
				y2 = pairs[i][1]
				continue
			elif y == 0:
				if y1 in pairs[i] and y2 in pairs[i]:
					pass
				elif y1 in pairs[i]:
					y = y1
				elif y2 in pairs[i]:
					y = y2
				else:
					flag2 = False
					break
			elif y not in pairs[i]:
				flag2 = False
				break
if flag or flag2:
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, M) = getInts()
	vals = []
	for m in range(M):
		vals.append(tuple(sorted(getInts())))
	if M <= 2:
		return 'YES'
	vals.sort()
	(a, b) = vals.pop(0)
	(c, d) = vals.pop()
	if a == c and b == d:
		return 'YES'
	if a == c:
		candidates = [(b, d), (a, a)]
	elif b == c:
		candidates = [(a, d), (b, b)]
	elif b == d:
		candidates = [(a, c), (b, b)]
	else:
		candidates = [(a, c), (a, d), (b, c), (b, d)]

	def works(x, y):
		if x == y:
			ops = []
			for (a, b) in vals:
				if a == x or b == x:
					continue
				if not ops:
					ops = [a, b]
					continue
				else:
					for j in range(len(ops) - 1, -1, -1):
						if ops[j] not in [a, b]:
							ops.pop(j)
				if not ops:
					return False
			return True
		else:
			for (a, b) in vals:
				if a not in [x, y] and b not in [x, y]:
					return False
			return True
	for (x, y) in candidates:
		if works(x, y):
			return 'YES'
	return 'NO'
print(solve())


(n, m) = list(map(int, input().split()))
a = []
for i in range(m):
	a.append(list(map(int, input().split())))
x = a[0][0]
for i in range(1, m):
	if not x in a[i]:
		y = a[i][0]
		for j in range(i + 1, m):
			if not x in a[j] and (not y in a[j]):
				break
		else:
			print('YES')
			exit()
		y = a[i][1]
		for j in range(i + 1, m):
			if not x in a[j] and (not y in a[j]):
				break
		else:
			print('YES')
			exit()
		break
else:
	print('YES')
	exit()
x = a[0][1]
for i in range(1, m):
	if not x in a[i]:
		y = a[i][0]
		for j in range(i + 1, m):
			if not x in a[j] and (not y in a[j]):
				break
		else:
			print('YES')
			exit()
		y = a[i][1]
		for j in range(i + 1, m):
			if not x in a[j] and (not y in a[j]):
				break
		else:
			print('YES')
			exit()
		break
else:
	print('YES')
	exit()
print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
list = {}
value = False
No = True
for i in range(m):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	list[i] = (a, b)
x = list[0][0]
y = list[0][0]
ans = 0
for i in range(m):
	if x == list[i][0] or x == list[i][1] or y == list[i][0] or (y == list[i][1]):
		ans += 1
	elif not value:
		y = list[i][0]
		l = i
		ans += 1
		value = True
if ans == m:
	No = False
	print('YES')
else:
	y = list[l][1]
	ans = 0
	for i in range(m):
		if x == list[i][0] or x == list[i][1] or y == list[i][0] or (y == list[i][1]):
			ans += 1
	if ans == m:
		print('YES')
		No = False
	else:
		value = False
		x = list[0][1]
		y = list[0][0]
		ans = 0
		for i in range(m):
			if x == list[i][0] or x == list[i][1] or y == list[i][0] or (y == list[i][1]):
				ans += 1
			elif not value and i != m - 1:
				y = list[i][0]
				l = i
				ans += 1
				value = True
		if ans == m:
			print('YES')
			No = False
		else:
			y = list[l][1]
			ans = 0
			for i in range(m):
				if x == list[i][0] or x == list[i][1] or y == list[i][0] or (y == list[i][1]):
					ans += 1
			if ans == m:
				print('YES')
				No = False
if No == True:
	print('NO')


import sys
cases = [int(i) for i in input().split(' ')][1]
pos = [int(j) for j in input().split(' ')]
lns = []
f = False
wds = ['NO', 'YES']
ft = True
for i in pos:
	dp = []
	first = True
	for j in range(0, cases - 1):
		if ft:
			lns.append([int(k) for k in sys.stdin.readline().rstrip().split(' ')])
		if i in lns[j]:
			continue
		elif first:
			dp = lns[j]
			first = False
		ndp = []
		if lns[j][0] in dp and lns[j][0] != i:
			ndp.append(lns[j][0])
		if lns[j][1] in dp and lns[j][1] != i:
			ndp.append(lns[j][1])
		dp = ndp
	if len(dp) > 0 or first:
		f = True
	ft = False
print(wds[f])


(n, m) = map(int, input().split())
pairs = []
for i in range(m):
	(p1, p2) = map(int, input().split())
	pairs.append((p1, p2))
x0 = pairs[0][0]
y0 = pairs[0][1]
restx = list(filter(lambda x: x0 not in x, pairs))
resty = list(filter(lambda x: y0 not in x, pairs))
if len(restx) == 0 or len(resty) == 0:
	print('YES')
	exit()
else:
	x0 = restx[0][0]
	y0 = restx[0][1]
	x1 = resty[0][0]
	y1 = resty[0][1]
	restx0 = list(filter(lambda x: x0 not in x, restx))
	resty0 = list(filter(lambda x: y0 not in x, restx))
	restx1 = list(filter(lambda x: x1 not in x, resty))
	resty1 = list(filter(lambda x: y1 not in x, resty))
if len(restx0) == 0 or len(resty0) == 0 or len(restx1) == 0 or (len(resty1) == 0):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
arr = []
for i in range(m):
	(x, y) = map(int, input().split())
	arr.append((x, y))
x1 = -1
x2 = -1
y1 = -1
y2 = -1
(x, y) = (arr[0][0], arr[0][1])
for i in arr:
	if i[0] != x and i[1] != x and (i[0] != y) and (i[1] != y):
		x1 = x
		y1 = y
		x2 = i[0]
		y2 = i[1]
		break
if x1 == -1:
	print('YES')
	exit()
for (x, y) in ((x1, y1), (x1, x2), (x1, y2), (x2, y1), (x2, y2), (y1, y2)):
	for itr in arr:
		if itr[0] != x and itr[1] != x and (itr[0] != y) and (itr[1] != y):
			break
	else:
		print('YES')
		exit()
print('NO')


import sys
from collections import defaultdict
input = sys.stdin.readline

class Problem:

	def __init__(self):
		pass

	def solve(self):
		print(self._solve())

	def _solve(self):
		(n, m) = [int(item) for item in input().split()]
		pairs = []
		cnt = {}
		mp = defaultdict(int)
		for i in range(m):
			pair = sorted([int(item) for item in input().split()])
			pairs.append(pair)
			mp[pair[0]] += 1
			mp[pair[1]] += 1
			pair = tuple(pair)
			if pair in cnt:
				cnt[pair] += 1
			else:
				cnt[pair] = 1
		res = []
		for x in mp:
			res.append([mp[x], x])
		res.sort()
		for i in range(len(res) - 1, -1, -1):
			for j in range(len(res) - 1, i, -1):
				if res[i][0] + res[j][0] < m:
					break
				pair = tuple(sorted([res[i][1], res[j][1]]))
				if pair[0] == pair[1]:
					continue
				if not pair in cnt:
					occs = 0
				else:
					occs = cnt[pair]
				if res[i][0] + res[j][0] - occs == m:
					return 'YES'
		return 'NO'

def main():
	problem = Problem()
	problem.solve()

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(m)]
p = a[0]
first = p[0]
second = -1
a = set(a)
for el in a:
	if first != el[0] and first != el[1]:
		if second == -1:
			second = el[0]
		elif second != el[0] and second != el[1]:
			break
else:
	print('YES')
	exit()
second = -1
for el in a:
	if first != el[0] and first != el[1]:
		if second == -1:
			second = el[1]
		elif second != el[0] and second != el[1]:
			break
else:
	print('YES')
	exit()
first = p[1]
second = -1
for el in a:
	if first != el[0] and first != el[1]:
		if second == -1:
			second = el[0]
		elif second != el[0] and second != el[1]:
			break
else:
	print('YES')
	exit()
second = -1
for el in a:
	if first != el[0] and first != el[1]:
		if second == -1:
			second = el[1]
		elif second != el[0] and second != el[1]:
			break
else:
	print('YES')
	exit()
print('NO')


(n, m) = [int(t) for t in input().split(' ')]
pair = [int(t) for t in input().split(' ')]
candidates = [(pair[0], None), (pair[1], None), (pair[0], pair[1])]
for i in range(m - 1):
	if not candidates:
		break
	pair = [int(t) for t in input().split(' ')]
	new = []
	for c in candidates:
		if any((p in c for p in pair)):
			new.append(c)
		elif None in c:
			new.append((c[0], pair[0]))
			new.append((c[0], pair[1]))
	candidates = new
print('YES' if candidates else 'NO')


(n, m) = map(int, input().split())
a = []
for i in range(m):
	a.append(tuple(map(int, input().split())))
for i in a[0]:
	kol = 0
	b = [0] * (n + 1)
	for c in a:
		if c[0] != i and c[1] != i:
			b[c[0]] += 1
			b[c[1]] += 1
			kol += 1
	if kol == max(b):
		print('YES')
		exit(0)
print('NO')


def f(c):
	if c:
		print('YES')
		exit()
(n, m) = map(int, input().split())
cnt = [0] * n
l = [[*map(int, input().split())] for _ in range(m)]
f(m == 1)
for x in l[0]:
	i = 1
	while i < m and x in l[i]:
		i += 1
	f(i == m)
	for y in l[i]:
		j = i + 1
		while j < m and (x in l[j] or y in l[j]):
			j += 1
		f(j == m)
print('NO')


(n, m) = [int(i) for i in input().split(' ')]
a = []
for i in range(m):
	a.append([int(i) for i in input().split(' ')])
for i in (a[0][0], a[0][1]):
	myset = set((i for i in range(1, n + 1)))
	for x in a[1:]:
		if i not in x:
			myset.intersection_update(set(x))
	if len(myset):
		exit(print('YES'))
print('NO')


import sys

def ch1(arr, x, y):
	for i in arr:
		if not (i[0] == x or i[0] == y or i[1] == x or (i[1] == y)):
			return False
	return True

def ch(arr, x):
	for i in arr:
		if i[0] != x and i[1] != x:
			if ch1(arr, x, i[0]):
				return i[0]
			if ch1(arr, x, i[1]):
				return i[1]
			return -1
	if x != 1:
		return 1
	return 2
(m, n) = input().split()
n = int(n)
m = int(m)
arr = []
for i in range(n):
	arr.append(input().split())
t = ch(arr, arr[0][0])
if t != -1:
	print('YES')
	sys.exit()
t = ch(arr, arr[0][1])
if t != -1:
	print('YES')
	sys.exit()
print('NO')


(bound, m) = [int(x) for x in input().split()]
if m == 1:
	print('YES')
	exit(0)
pairs_uniq = set()
for _ in range(m):
	x = [int(x) for x in input().split()]
	x.sort()
	pairs_uniq.add((x[0], x[1]))
if len(pairs_uniq) == 1:
	print('YES')
	exit(0)
pairs = [x for x in pairs_uniq]
for x in pairs[0]:
	no_x_pairs = [n for n in pairs if n[0] != x and n[1] != x]
	x_pairs_count = 0
	d = {}
	for (i, j) in pairs:
		if i != x and j != x:
			if i not in d:
				d[i] = 0
			d[i] += 1
			if j not in d:
				d[j] = 0
			d[j] += 1
		else:
			x_pairs_count += 1
	max_ = 0 if len(d.values()) == 0 else sorted(d.values())[-1]
	if max_ + x_pairs_count == len(pairs):
		print('YES')
		exit(0)
print('NO')


from copy import copy
(n, m) = map(int, input().split())
P = []
z = set()
for i in range(1, n + 1):
	z.add(i)
for i in range(m):
	P.append(list(map(int, input().split())))
for x in (P[0][0], P[0][1]):
	s = copy(z)
	for i in range(1, m):
		(a, b) = P[i]
		if a != x and b != x:
			s.intersection_update({a, b})
	if len(s):
		print('YES')
		exit(0)
print('NO')


(n, p) = map(int, input().split())
d = {}
c = []
m = {}
for _ in range(p):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a not in d:
		d[a] = 1
	else:
		d[a] += 1
	if b not in d:
		d[b] = 1
	else:
		d[b] += 1
	if (a, b) not in m:
		m[a, b] = 1
	else:
		m[a, b] += 1
l = []
flag = 0
for (k1, v1) in d.items():
	if flag:
		break
	if v1 == p - 1:
		flag = 1
		break
	if v1 < p // 2:
		continue
	for (k2, v2) in d.items():
		if v1 + v2 < p:
			continue
		if k1 != k2:
			(d1, d2) = (k1, k2)
			if k1 > k2:
				d1 = k2
				d2 = k1
			if (d1, d2) not in m and v1 + v2 == p:
				flag = 1
				break
			elif (d1, d2) in m and v1 + v2 - m[d1, d2] == p:
				flag = 1
				break
if flag:
	print('YES')
else:
	print('NO')


def solution(pairs):
	((a, b), *rest) = pairs
	without_a = [(x, y) for (x, y) in pairs if x != a and y != a]
	if len(without_a) == 0:
		return True
	((c, d), *rest2) = without_a
	without_a_c = [(x, y) for (x, y) in without_a if x != c and y != c]
	if len(without_a_c) == 0:
		return True
	without_a_d = [(x, y) for (x, y) in without_a if x != d and y != d]
	if len(without_a_d) == 0:
		return True
	without_b = [(x, y) for (x, y) in pairs if x != b and y != b]
	if len(without_b) == 0:
		return True
	((c, d), *rest2) = without_b
	without_b_c = [(x, y) for (x, y) in without_b if x != c and y != c]
	if len(without_b_c) == 0:
		return True
	without_b_d = [(x, y) for (x, y) in without_b if x != d and y != d]
	if len(without_b_d) == 0:
		return True
	return False
(n, m) = [int(x) for x in input().split()]
pairs = []
for _ in range(m):
	(a, b) = [int(x) for x in input().split()]
	pairs.append((a, b))
if solution(pairs):
	print('YES')
else:
	print('NO')


pa = []
(n, m) = list(map(int, input().split()))

def check(tup):
	global pa, n, m
	for (f, s) in pa:
		if f not in tup and s not in tup:
			return False
	return True

def forward(first):
	global pa, n, m
	for j in pa:
		if first not in j:
			if check((first, j[0])) or check((first, j[1])):
				return True
			else:
				return False
	return True
for i in range(m):
	pa.append(tuple(map(int, input().split())))
if forward(pa[0][0]) or forward(pa[0][1]):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(a, b) = map(int, input().split())
s = set()
s1 = set()
s.add(a)
s.add(b)
l = [[a, b]]
tag = True
for i in range(m - 1):
	l.append(list(map(int, input().split())))
for i in range(len(l)):
	if a not in l[i] and b not in l[i]:
		s1.add(l[i][0])
		s1.add(l[i][1])
		tag = False
		break
if tag:
	print('YES')
else:
	tag = True
	t = 0
	for i in s:
		for j in s1:
			for k in l:
				if i not in k and j not in k:
					t = -1
					break
			if t == 0:
				print('YES')
				exit()
			t = 0
	print('NO')


def ok(pairs, x):
	y = -1
	ind = 0
	for i in range(len(pairs)):
		(a, b) = pairs[i]
		if a != x and b != x:
			break
		ind += 1
	if ind == len(pairs):
		return True
	y = pairs[ind][0]
	tmp = True
	for i in range(ind + 1, len(pairs)):
		(a, b) = pairs[i]
		if a != x and a != y and (b != x) and (b != y):
			tmp = False
			break
	if tmp:
		return True
	y = pairs[ind][1]
	for i in range(ind + 1, len(pairs)):
		(a, b) = pairs[i]
		if a != x and a != y and (b != x) and (b != y):
			return False
	return True

def B():
	(n, m) = [int(x) for x in input().split()]
	orig_pairs = []
	for i in range(m):
		(a, b) = [int(x) for x in input().split()]
		orig_pairs.append((a, b))
	if ok(orig_pairs, orig_pairs[0][0]) or ok(orig_pairs, orig_pairs[0][1]):
		print('YES')
	else:
		print('NO')
B()


def solve(n, pairs):
	X = pairs.pop()
	for x in X:
		y_candidates = {}
		total = 0
		for p in pairs:
			if x not in p:
				y_candidates[p[0]] = y_candidates.get(p[0], 0) + 1
				y_candidates[p[1]] = y_candidates.get(p[1], 0) + 1
				total += 1
		if total == 0 and y_candidates == {} or max(y_candidates.values()) == total:
			print('YES')
			return
	print('NO')
(n, m) = map(int, input().split(' '))
pairs = set()
unique_values = set()
for i in range(m):
	(a, b) = map(int, input().split(' '))
	pairs.add((a, b))
solve(n, pairs)


(n, m) = map(int, input().split())
a = []
for i in range(m):
	a.append(list(map(int, input().split())))
for i in a[0]:
	cnt = 0
	nl = [0] * (n + 1)
	for j in a:
		if j[0] != i and j[1] != i:
			nl[j[0]] += 1
			nl[j[1]] += 1
			cnt += 1
	if cnt == max(nl):
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
freq = dict()
tset = set()
for i in range(m):
	(x, y) = map(int, input().split())
	tset.add((x, y))
m = len(tset)
for item in tset:
	if item[0] in freq:
		freq[item[0]] += 1
	else:
		freq[item[0]] = 1
	if item[1] in freq:
		freq[item[1]] += 1
	else:
		freq[item[1]] = 1
key = list(freq.keys())
(temp, ind) = (-1, -1)
for i in range(len(key)):
	if freq[key[i]] > temp:
		temp = freq[key[i]]
		ind = key[i]
for i in range(len(key)):
	if key[i] == ind:
		continue
	temp2 = freq[key[i]] + temp
	if temp2 == m:
		if (ind, key[i]) not in tset and (key[i], ind) not in tset:
			print('YES')
			exit()
	elif temp2 > m:
		print('YES')
		exit()
print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m) = sep()
	storage = []
	for i in range(m):
		(a, b) = sep()
		storage.append([a, b])
	ff = storage[0]
	ss = -1
	for i in range(m):
		if ff[0] in storage[i] or ff[1] in storage[i]:
			continue
		else:
			ss = storage[i]
			break
	if ss == -1:
		print('YES')
		return
	for i in range(2):
		for j in range(2):
			a = ff[i]
			b = ss[j]
			f = True
			for ii in range(m):
				if a in storage[ii] or b in storage[ii]:
					continue
				else:
					f = False
					break
			if f:
				print('YES')
				return
	print('NO')
testcase(1)


(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(m)]
a = arr[0][0]
b = arr[0][1]
arr1 = []
arr2 = []
for i in range(m):
	if a not in arr[i]:
		arr1.append(arr[i])
	if b not in arr[i]:
		arr2.append(arr[i])
try:
	s1 = set(arr1[0])
	for i in arr1:
		s1 = s1.intersection(set(i))
	s2 = set(arr2[0])
	for i in arr2:
		s2 = s2.intersection(set(i))
	s1 = list(s1)
	s2 = list(s2)
	if len(s1) >= 1 or len(s2) >= 1 or arr1 == [] or (arr2 == []):
		print('YES')
	else:
		print('NO')
except:
	print('YES')


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
pairs = []

def check(x, y):
	for p in pairs:
		if p[0] != x and p[1] != x and (p[0] != y) and (p[1] != y):
			return False
	return True

def solve():
	(n, m) = map(int, input().split())
	for q in range(m):
		(a, b) = map(int, input().split())
		pairs.append((a, b))
	for x in pairs[0]:
		if check(x, -1):
			print('YES')
			exit()
		for p in pairs:
			if p[0] != x and p[1] != x:
				if check(x, p[0]) or check(x, p[1]):
					print('YES')
					exit()
				break
	print('NO')
for _ in range(1):
	solve()


import sys
(n, m) = map(int, input().split(' '))
A = set()
L = [sys.stdin.readline() for _ in range(m)]
C = [0] * n
for l in L:
	(a, b) = map(int, l.split(' '))
	if a > b:
		(a, b) = (b, a)
	A.add((a, b))
for a in A:
	C[a[0] - 1] += 1
	C[a[1] - 1] += 1
max_idx = -1
max_v = 0
for i in range(n):
	if max_v < C[i]:
		max_idx = i
		max_v = C[i]
max_n = max_idx + 1
B = set()
for a in A:
	if max_n not in a:
		B.add(a)
D = [0] * n
for b in B:
	D[b[0] - 1] += 1
	D[b[1] - 1] += 1
max_idx = -1
max_v = 0
for i in range(n):
	if max_v < D[i]:
		max_idx = i
		max_v = D[i]
max_n = max_idx + 1
for b in B:
	if max_n not in b:
		print('NO')
		break
else:
	print('YES')


if False:
	(n, m) = map(int, input().split())
	pairs = []
	for _ in range(m):
		(x, y) = map(int, input().split())
		pairs.append((x, y))
else:
	import sys
	(n, m, *arr) = map(int, sys.stdin.read().split())

def check(v):
	cand = dict()
	other = 0
	max_ = 0
	for i in range(0, len(arr), 2):
		(x, y) = (arr[i], arr[i + 1])
		if x != v and y != v:
			cand[x] = cand.get(x, 0) + 1
			cand[y] = cand.get(y, 0) + 1
			max_ = max(max_, cand[x])
			max_ = max(max_, cand[y])
			other += 1
	if other == 0 or max_ == other:
		return True
	return False

def solve():
	(x, y) = (arr[0], arr[1])
	if check(x):
		return True
	if check(y):
		return True
	return False
print('YES' if solve() else 'NO')


def test(c1, c2):
	flag = True
	for pair in pairs:
		if c1 not in pair and c2 not in pair:
			flag = False
	return flag
(n, m) = map(int, input().split())
pairs = []
for i in range(0, m):
	(x, y) = map(int, input().split())
	pairs.append((x, y))
w = pairs[0][0]
y = pairs[0][1]
e = ' '
r = ' '
for pair in pairs:
	if w not in pair and y not in pair:
		e = pair[0]
		r = pair[1]
		break
if test(w, e) or test(w, r) or test(y, e) or test(y, r) or test(w, y):
	print('YES')
else:
	print('NO')


def process(A):
	(x, y) = A[0]
	start = set([(x, y)])
	a1 = None
	b1 = None
	for (a, b) in A[1:]:
		if x != a and x != b and (y != a) and (y != b):
			a1 = a
			b1 = b
			start.add((x, a1))
			start.add((x, b1))
			start.add((y, a1))
			start.add((y, b1))
			break
	if b1 is None or a1 is None:
		return 'YES'
	for (x, y) in start:
		working = True
		for (a, b) in A:
			if x != a and x != b and (y != a) and (y != b):
				working = False
				break
		if working:
			return 'YES'
	return 'NO'
(n, m) = [int(x) for x in input().split()]
A = []
for i in range(m):
	(x, y) = [int(c) for c in input().split()]
	A.append([x, y])
print(process(A))


input = __import__('sys').stdin.readline
(n, m) = map(int, input().split())
aa = []
for i in range(m):
	(a, b) = map(int, input().split())
	aa.append([a, b])
for i in range(2):
	indx = aa[0][i]
	dd = [0] * (n + 1)
	ans = 0
	for j in aa:
		if j[0] != indx and j[1] != indx:
			dd[j[0]] += 1
			dd[j[1]] += 1
			ans += 1
	if max(dd) == ans:
		print('YES')
		exit()
print('NO')


ls = input().split()
ls[0] = int(ls[0])
ls[1] = int(ls[1])
a = input().split()
r = []
z = 1
for i in range(ls[1] - 1):
	r.append(input().split())
for j in range(2):
	x = a[j]
	s = []
	for i in r:
		if x not in i:
			s.append(i)
	if len(s) == 0 and z:
		print('YES')
		z = 0
		break
	elif len(s):
		for k in range(2):
			q = s[0][k]
			k = 0
			for i in range(1, len(s)):
				if q in s[i]:
					k = k + 1
			if k == len(s) - 1 and z:
				print('YES')
				z = 0
				break
if z:
	print('NO')


class Pair:

	def __init__(self, x, y):
		self._data = _data = [x, y]

	def __setitem__(self, key, value):
		self._data[key] = value

	def __getitem__(self, key):
		return self._data[key]

	def __len__(self):
		return len(_data)

	def __repr__(self):
		return '{' + str(self._data[0]) + ',' + str(self._data[1]) + '}'
(n, m) = map(int, input().split())
v = []
d = dict()
for i in range(m):
	(f, s) = map(int, input().split())
	v.append(Pair(f, s))
value = [v[0][0], v[0][1]]
flag = False
for x in value:
	val = [0] * (n + 1)
	a = 0
	for y in v:
		if y[0] != x and y[1] != x:
			a += 1
			val[y[0]] += 1
			val[y[1]] += 1
	if max(val) == a:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


nums = [int(x) for x in input().split()]
m = nums[0]
n = nums[1]
pos = False
numbers = [int(x) for x in input().split()]
r = numbers[:]
r.sort()
f = []
g = []
hasntbeenNumZero = False
hasntbeenNumOne = False

def find_letter(letter, lst):
	for i in range(len(lst)):
		if lst[i] == letter:
			return True
	return False
for i in range(n - 1):
	numbers = [int(x) for x in input().split()]
	if find_letter(r[0], numbers) == False:
		if hasntbeenNumZero == False:
			hasntbeenNumZero = True
			f = numbers[:]
		else:
			for l in range(len(f)):
				if find_letter(f[len(f) - 1 - l], numbers) == False:
					f.pop(len(f) - 1 - l)
	if find_letter(r[1], numbers) == False:
		if hasntbeenNumOne == False:
			hasntbeenNumOne = True
			g = numbers[:]
		else:
			for l in range(len(g)):
				if find_letter(g[len(g) - 1 - l], numbers) == False:
					g.pop(len(g) - 1 - l)
if hasntbeenNumZero == False or hasntbeenNumOne == False or len(f) != 0 or (len(g) != 0):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [[*map(int, input().split())] for _ in range(m)]
try:
	for x in a[0]:
		p = next((p for p in a if x not in p))
		for y in p:
			next((0 for p in a if x not in p and y not in p))
	a = 1
except:
	a = 0
print('YNEOS'[a::2])


from __future__ import division, print_function

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

def get_array():
	return list(map(int, input().strip().split()))
mod = 1000000007
import collections, math, sys, bisect
INF = sys.maxsize
MOD = 998244353

def main():

	def check(a, b, arr):
		for i in arr:
			if i[0] != a and i[1] != b and (i[0] != b) and (i[1] != a):
				return False
		return True

	def solve():
		(n, m) = get_ints()
		arr = []
		for i in range(m):
			(a, b) = get_ints()
			arr.append((a, b))
		for x in arr[0]:
			if check(x, -1, arr):
				print('YES')
				return
			for i in range(1, len(arr)):
				if arr[i][0] != x and arr[i][1] != x:
					if check(x, arr[i][0], arr) or check(x, arr[i][1], arr):
						print('YES')
						return
					break
		print('NO')
	solve()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
(n, m) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(m)]
x = (a[0][0], a[0][1])
y = []
for i in a:
	if x[0] not in i:
		y.append(i)
		break
if len(y) == 0:
	y = [[-1, -1]]
for i in a:
	if x[1] not in i:
		y.append(i)
if len(y) == 1:
	y.append([-1, -1])
for j in range(2):
	for k in range(2):
		for i in a:
			if x[j] not in i and y[j][k] not in i:
				break
		else:
			print('YES')
			sys.exit()
print('NO')


(n, m) = map(int, input().split())
pairs = []
for i in range(m):
	(a, b) = map(int, input().split())
	pairs.append((a, b))

def iterate(pairs, x, m):
	ct_rem = [0] * (n + 1)
	ctx = 1
	for i in range(1, m):
		(a, b) = pairs[i]
		if a != x and b != x:
			ct_rem[a] += 1
			ct_rem[b] += 1
		else:
			ctx += 1
	remaining = m - ctx
	for v in ct_rem:
		if v == remaining:
			return True
	return False
if iterate(pairs, pairs[0][0], m):
	print('YES')
elif iterate(pairs, pairs[0][1], m):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = {}
k = []
for i in range(m):
	(x, y) = map(int, input().split())
	k.append([x, y])
t = True
i = 1
p1 = k[0][0]
p2 = k[0][1]
while i < m and t:
	if k[i][0] not in [p1, p2] and k[i][1] not in [p1, p2]:
		p3 = k[i][0]
		p4 = k[i][1]
		j = i
		t = False
	i += 1
if t:
	print('YES')
else:
	b = 0
	p = [p1, p3]
	for i in range(m):
		if k[i][0] not in p and k[i][1] not in p:
			b += 1
			break
	p = [p2, p3]
	for i in range(m):
		if k[i][0] not in p and k[i][1] not in p:
			b += 1
			break
	p = [p1, p4]
	for i in range(m):
		if k[i][0] not in p and k[i][1] not in p:
			b += 1
			break
	p = [p2, p4]
	for i in range(m):
		if k[i][0] not in p and k[i][1] not in p:
			b += 1
			break
	if b < 4:
		print('YES')
	else:
		print('NO')


def acha(ar, x, y, b):
	for i in range(b):
		if (ar[i][0] != x and ar[i][0] != y) and (ar[i][1] != x and ar[i][1] != y):
			return False
	return True
(a, b) = map(int, input().split())
ar = []
for i in range(b):
	l = list(map(int, input().split()))
	ar.append(l)
x1 = ar[0][0]
x2 = ar[0][1]
y1 = [0, 0]
y2 = [0, 0]
for i in range(b):
	if ar[i][0] != x1 and ar[i][1] != x1:
		y1[0] = ar[i][0]
		y1[1] = ar[i][1]
		break
for i in range(b):
	if ar[i][0] != x2 and ar[i][1] != x2:
		y2[0] = ar[i][0]
		y2[1] = ar[i][1]
		break
ans1 = acha(ar, x1, y1[0], b)
ans2 = acha(ar, x1, y1[1], b)
ans3 = acha(ar, x2, y2[0], b)
ans4 = acha(ar, x2, y2[1], b)
if ans1 == False and ans2 == False and (ans3 == False) and (ans4 == False):
	print('NO')
else:
	print('YES')


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

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

def stringIn():
	return stdin.readline().strip()
(n, m) = listIn()
di = defaultdict(int)
li = []
Arr = defaultdict(list)
for i in range(m):
	(a, b) = listIn()
	li.append((a, b))
	Arr[a].append(i + 1)
	Arr[b].append(i + 1)
	di[a] += 1
	di[b] += 1
(a, b) = (li[0][0], li[0][1])
li2 = []
li2.append(a)
li2.append(b)
f = 1
for i in range(1, m):
	if a not in li[i] and b not in li[i]:
		f = 0
		li2.append(li[i][0])
		li2.append(li[i][1])
		break
if f:
	print('YES')
else:
	f = 0
	for i in [0, 1]:
		s = set(Arr[li2[i]])
		for j in [2, 3]:
			s1 = s | set(Arr[li2[j]])
			if len(s1) == m:
				f = 1
				break
		if f:
			break
	if f:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
l = [set() for i in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	l[a - 1].add(b - 1)
	l[b - 1].add(a - 1)
max1 = 0
max2 = 0
k1 = 0
k2 = 0
s = 0
for i in range(n):
	if len(l[i]) > max1:
		max1 = len(l[i])
		k1 = i
	s += len(l[i])
s = s // 2
for i in range(n):
	t = len(l[i])
	if i in l[k1]:
		if t - 1 > max2:
			max2 = t - 1
	elif i != k1:
		if t > max2:
			max2 = t
if max1 + max2 == s:
	print('YES')
else:
	print('NO')


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

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

def lm():
	return list(map(int, input().split()))
(n, m) = mi()
data = []
for i in range(m):
	data.append(lm())

def tryx(num):
	ytry = None
	for i in range(1, len(data)):
		next = data[i]
		if num in next:
			continue
		elif not ytry:
			ytry = next
		elif len(ytry) == 1:
			if ytry[0] in next:
				continue
			else:
				return False
		elif sorted(next) == sorted(ytry):
			ytry = next
		elif next[0] in ytry:
			ytry = [next[0]]
		elif next[1] in ytry:
			ytry = [next[1]]
		else:
			return False
	return True
if tryx(data[0][0]) or tryx(data[0][1]):
	print('Yes')
else:
	print('No')


from collections import defaultdict
import sys

def input():
	return sys.stdin.readline().strip()
(n, m) = map(int, input().split())
pairs = []
for i in range(m):
	(a, b) = map(int, input().split())
	pairs.append([a, b])
ans = [pairs[0][0], pairs[0][1]]
counter = 0
for el in ans:
	dic = defaultdict(int)
	count = 0
	for i in range(1, m):
		if pairs[i][0] != el and pairs[i][1] != el:
			count += 1
			dic[pairs[i][0]] += 1
			dic[pairs[i][1]] += 1
	if len(dic) == 0 or max(dic.values()) == count:
		counter = 1
		break
if counter:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().strip().split())
can = False
pairs = []
for i in range(m):
	(a, b) = map(int, input().strip().split())
	pairs.append([a, b])
first = pairs[0][0]
missed = []
for i in range(m):
	if pairs[i][0] != first and pairs[i][1] != first:
		missed.append(i)
if missed != []:
	ind = missed[0]
	second = pairs[ind][0]
	test = True
	for i in range(len(missed)):
		if second != pairs[missed[i]][0] and second != pairs[missed[i]][1]:
			test = False
			break
	if test == True:
		can = True
	second = pairs[ind][1]
	test = True
	for i in range(len(missed)):
		if second != pairs[missed[i]][0] and second != pairs[missed[i]][1]:
			test = False
			break
	if test == True:
		can = True
else:
	can = True
first = pairs[0][1]
missed = []
for i in range(m):
	if pairs[i][0] != first and pairs[i][1] != first:
		missed.append(i)
if missed != []:
	ind = missed[0]
	second = pairs[ind][0]
	test = True
	for i in range(len(missed)):
		if second != pairs[missed[i]][0] and second != pairs[missed[i]][1]:
			test = False
			break
	if test == True:
		can = True
	second = pairs[ind][1]
	test = True
	for i in range(len(missed)):
		if second != pairs[missed[i]][0] and second != pairs[missed[i]][1]:
			test = False
			break
	if test == True:
		can = True
else:
	can = True
if can == True:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

def go():
	for x in a[0]:
		for i in range(1, m):
			if x not in a[i]:
				for y in a[i]:
					for j in range(i + 1, m):
						if x not in a[j] and y not in a[j]:
							break
					else:
						return sorted([x, y])
				break
		else:
			return [x, x + 1]
	return []
print('YES' if go() else 'NO')


(ure, nre) = list(map(int, input().split()))
lolly = [list(map(int, input().split())) for i in range(nre)]
import sys
xre = lolly[0][0]
for i in range(nre):
	if xre not in lolly[i]:
		yre = lolly[i][0]
		zre = lolly[i][1]
		j = i
		break
	if i == nre - 1:
		print('YES')
		return
kre1 = 1
kre2 = 1
for i in range(j, nre):
	if xre not in lolly[i] and yre not in lolly[i]:
		kre1 = 0
		break
for i in range(j, nre):
	if xre not in lolly[i] and zre not in lolly[i]:
		kre2 = 0
		break
import sys
if kre1 == 1 or kre2 == 1:
	print('YES')
	return
xre = lolly[0][1]
for i in range(nre):
	if xre not in lolly[i]:
		yre = lolly[i][0]
		zre = lolly[i][1]
		j = i
		break
kre1 = 1
kre2 = 1
for i in range(j, nre):
	if xre not in lolly[i] and yre not in lolly[i]:
		kre1 = 0
		break
for i in range(j, nre):
	if xre not in lolly[i] and zre not in lolly[i]:
		kre2 = 0
		break
import sys
if kre1 == 1 or kre2 == 1:
	print('YES')
	return
print('NO')


(n, m) = map(int, input().split())
a = list()
b = list()
for _ in range(m):
	(c, d) = map(int, input().split())
	a.append(c)
	b.append(d)
x1 = a[0]
x2 = b[0]
k = list()
k.append(x1)
k.append(x2)
ans = 'NO'
for num in k:
	count = 0
	f = {}
	for bc in range(1, m):
		if num != a[bc] and num != b[bc]:
			count += 1
			p1 = a[bc]
			p2 = b[bc]
			if p1 in f:
				f[p1] += 1
			if p1 not in f:
				f[p1] = 1
			if p2 in f:
				f[p2] += 1
			if p2 not in f:
				f[p2] = 1
	if count == 0:
		print('YES')
		exit()
	if count == max(f.values()):
		print('YES')
		exit()
print('NO')


from itertools import combinations
(n, m) = list(map(int, input().split()))
c = [[] for i in range(n + 1)]
p = []
for i in range(m):
	(x, y) = list(map(int, input().split()))
	p.append([x, y])
x = p[0]
arr = [x[0], x[1]]
for i in p:
	if len(set(x).intersection(set(i))) == 0:
		arr.append(i[0])
		arr.append(i[1])
		break
for i in range(m):
	for j in arr:
		if j in p[i]:
			c[j].append(i)
x = list(combinations(arr, 2))
req = [i for i in range(m)]
for i in x:
	n1 = i[0]
	n2 = i[1]
	if list(set(c[n1] + c[n2])) == req:
		print('YES')
		return
print('NO')


(n, m) = map(int, input().split())
a = []
for _ in range(m):
	(x, y) = map(int, input().split())
	a.append((x, y))
for i in a[0]:
	k = 0
	val = [0 for _ in range(n + 1)]
	for p in a:
		if p[0] != i and p[1] != i:
			val[p[0]] += 1
			val[p[1]] += 1
			k += 1
	if max(val) == k:
		print('YES')
		exit()
print('NO')


from collections import Counter
d = []
(n, m) = map(int, input().split())
(x1, x2) = map(int, input().split())
nx1 = []
nx2 = []
(nx1c, nx2c) = (0, 0)
for i in range(m - 1):
	lol = list(map(int, input().split()))
	if x1 not in lol:
		nx1.extend(list(set(lol)))
		nx1c += 1
	if x2 not in lol:
		nx2.extend(list(set(lol)))
		nx2c += 1
if len(nx1) == 0 or len(nx2) == 0:
	print('YES')
else:
	flag = 0
	cx1 = dict(Counter(nx1))
	cx2 = dict(Counter(nx2))
	for u in cx1.values():
		if u == nx1c:
			flag = 1
	for u in cx2.values():
		if u == nx2c:
			flag = 1
	print('YES' if flag == 1 else 'NO')


(n, m) = map(int, input().split())
arr = []
for i in range(m):
	(a, b) = map(int, input().split())
	arr.append([a, b])
if m <= 1:
	print('YES')
	exit()
x = arr[0][0]
y = arr[0][1]
ans = {}
ansy = {}
ind2 = 0
ind3 = 0
for a in arr:
	if x not in a:
		if a[0] not in ans:
			ans[a[0]] = 1
		else:
			ans[a[0]] += 1
		if a[1] not in ans:
			ans[a[1]] = 1
		else:
			ans[a[1]] += 1
	else:
		ind2 += 1
	if y not in a:
		if a[0] not in ansy:
			ansy[a[0]] = 1
		else:
			ansy[a[0]] += 1
		if a[1] not in ansy:
			ansy[a[1]] = 1
		else:
			ansy[a[1]] += 1
	else:
		ind3 += 1
if ans:
	ind2 += max(ans.values())
if ansy:
	ind3 += max(ansy.values())
if ind2 >= m or ind3 >= m:
	print('YES')
else:
	print('NO')


from sys import stdin
(n, m) = map(int, input().split())
lines = stdin.readlines()
arr = []
for line in lines:
	(a, b) = map(int, line.split())
	arr.append((a, b))

def check(x, arr):
	b = set()
	for a in arr:
		if x not in a:
			if not b:
				b = set(a)
			elif not b.intersection(set(a)):
				return False
			else:
				b = b.intersection(set(a))
	return True
if check(arr[0][0], arr):
	print('YES')
elif check(arr[0][1], arr):
	print('YES')
else:
	print('NO')


from sys import stdin, stdout

def find_union_universal_vertex(edges) -> str:

	def edge_to_x_or_y(x: int, y: int) -> bool:
		for edge in edges:
			if edge[0] != x and edge[0] != y and (edge[1] != x) and (edge[1] != y):
				return False
		return True
	for x in edges[0]:
		if edge_to_x_or_y(x, 0):
			return 'YES'
		for edge in edges:
			if edge[0] != x and edge[1] != x:
				if edge_to_x_or_y(x, edge[0]) or edge_to_x_or_y(x, edge[1]):
					return 'YES'
				break
	return 'NO'

def dp_probability_rule_of_sum(value_upperbound: int, edges) -> str:
	dp = [[0 for _ in range(value_upperbound + 1)] for _ in range(value_upperbound + 1)]
	for pair in edges:
		if pair[0] == pair[1]:
			dp[pair[0]][pair[0]] += 1
		else:
			dp[pair[0]][pair[0]] += 1
			dp[pair[1]][pair[1]] += 1
			dp[pair[0]][pair[1]] += 1
			dp[pair[1]][pair[0]] += 1
	for i in range(value_upperbound):
		for j in range(i + 1, value_upperbound):
			if dp[i][i] + dp[j][j] - dp[i][j] == len(edges):
				return 'YES'
	return 'NO'
(value_upperbound, n) = map(int, stdin.readline().rstrip().split(' '))
pairs = []
for _ in range(n):
	line = stdin.readline().rstrip().split(' ')
	pairs.append([int(line[0]), int(line[1])])
stdout.write(find_union_universal_vertex(pairs) + '\n')


inp = [int(e) for e in input().split(' ')]
p1 = True
p2 = True
ans = 'YES'
a = [int(e) for e in input().split(' ')]
v1 = a[0]
v2 = a[1]
s1 = -1
s2 = -1
for i in range(1, inp[1]):
	a = [int(e) for e in input().split(' ')]
	if p1:
		if v1 not in a:
			if s1 == -1:
				s1 = set(a)
			elif s1 & set(a) == set():
				p1 = False
			else:
				s1 = s1 & set(a)
	if p2:
		if v2 not in a:
			if s2 == -1:
				s2 = set(a)
			elif s2 & set(a) == set():
				p2 = False
			else:
				s2 = s2 & set(a)
	if not p1 and (not p2):
		break
if p1 or p2:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
c = []
for ai in range(m):
	c.append(input().split())
(a, b) = c[0]
ka = 0
kb = 0
db = {'a': 0}
da = {'a': 0}
for ai in c:
	if a not in ai:
		ka += 1
		da[ai[0]] = da.get(ai[0], 0) + 1
		da[ai[1]] = da.get(ai[1], 0) + 1
	if b not in ai:
		kb += 1
		db[ai[0]] = db.get(ai[0], 0) + 1
		db[ai[1]] = db.get(ai[1], 0) + 1
if ka == max(da.values()):
	print('YES')
elif kb == max(db.values()):
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
a = []
for i in range(m):
	a.append(list(map(int, input().split())))
b = [0] * m
for i in range(m):
	if a[0][0] in a[i] or a[0][1] in a[i]:
		b[i] = 1
if list(set(b)) == [1]:
	print('YES')
else:
	e = 0
	for i in range(2):
		b = [0] * m
		for j in range(m):
			if a[0][i] in a[j]:
				b[j] = 1
		for j in range(m):
			if b[j] == 0:
				k = j
				break
		for j in range(2):
			c = b.copy()
			for l in range(m):
				if a[k][j] in a[l]:
					c[l] = 1
			if list(set(c)) == [1]:
				e = 1
	if e == 1:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
pairs = []
d = set()
for i in range(m):
	(a, b) = map(int, input().split())
	pairs.append([a, b])
	if a not in d and b not in d:
		if len(d) >= 4:
			print('NO')
			exit()
		else:
			d.add(a)
			d.add(b)
d = list(d)
for i in range(len(d)):
	for j in range(i + 1, len(d)):
		s = set()
		s.add(d[i])
		s.add(d[j])
		f = True
		for p in pairs:
			if p[0] not in s and p[1] not in s:
				f = False
				break
		if f:
			print('YES')
			exit()
print('NO')


(n, m) = tuple(map(int, input().split()))
pairs = []
for i in range(m):
	pairs.append(tuple(map(int, input().split())))
d1 = pairs[0][0]
d2 = pairs[0][1]
k1 = -1
k2 = -1
(T1, T2) = (True, True)
for i in range(1, m):
	if pairs[i][0] == d1 or pairs[i][1] == d1:
		continue
	elif k1 == -1 and k2 == -1:
		k1 = pairs[i][0]
		k2 = pairs[i][1]
	elif k2 == -1 and (k1 == pairs[i][0] or k1 == pairs[i][1]):
		continue
	elif k1 == pairs[i][0] and k2 == pairs[i][1] or (k1 == pairs[i][1] and k2 == pairs[i][0]):
		continue
	elif k1 == pairs[i][0] or k1 == pairs[i][1]:
		k2 = -1
	elif k2 == pairs[i][0] or k2 == pairs[i][1]:
		k1 = k2
		k2 = -1
	else:
		T1 = False
k1 = -1
k2 = -1
for i in range(1, m):
	if pairs[i][0] == d2 or pairs[i][1] == d2:
		continue
	elif k1 == -1 and k2 == -1:
		k1 = pairs[i][0]
		k2 = pairs[i][1]
	elif k2 == -1 and (k1 == pairs[i][0] or k1 == pairs[i][1]):
		continue
	elif k1 == pairs[i][0] and k2 == pairs[i][1] or (k1 == pairs[i][1] and k2 == pairs[i][0]):
		continue
	elif k1 == pairs[i][0] or k1 == pairs[i][1]:
		k2 = -1
	elif k2 == pairs[i][0] or k2 == pairs[i][1]:
		k1 = k2
		k2 = -1
	else:
		T2 = False
if T1 or T2:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
(a, b) = ([], [])

def test(index, first, second):
	outcome = False
	while True:
		if index >= 0:
			outcome = True
			break
		elif first == -1:
			outcome = test(index + 1, a[index], second) or test(index + 1, b[index], second)
			break
		elif a[index] == first or b[index] == first:
			index += 1
		elif second == -1:
			outcome = test(index + 1, first, a[index]) or test(index + 1, first, b[index])
			break
		elif a[index] == second or b[index] == second:
			index += 1
		else:
			break
	return outcome

def main():
	(n, m) = [int(i) for i in stdin.readline().split()]
	for i in range(m):
		(x, y) = [int(j) for j in stdin.readline().split()]
		a.append(x)
		b.append(y)
	outcome = test(-m, -1, -1)
	if outcome:
		print('YES')
	else:
		print('NO')
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = []
for i in range(m):
	(a, b) = map(int, input().split())
	l.append((a, b))
e1 = l[0][0]
e2 = l[0][1]
f = 0
g = 0
for x in l:
	a = x[0]
	b = x[1]
	if a == e1 or b == e1:
		continue
	elif f == 0:
		s = set()
		s.add(a)
		s.add(b)
		f = 1
	else:
		s = s & {a, b}
		if len(s) == 0:
			g = 1
			break
if g == 0:
	print('YES')
	exit()
g = 0
f = 0
for x in l:
	a = x[0]
	b = x[1]
	if a == e2 or b == e2:
		continue
	elif f == 0:
		s = set()
		s.add(a)
		s.add(b)
		f = 1
	else:
		s = s & {a, b}
		if len(s) == 0:
			g = 1
			break
if g == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(a, b) = map(int, input().split())
ans = 1
l1 = []
l2 = []
for i in range(m - 1):
	(x, y) = map(int, input().split())
	if x != a and y != a:
		l1.append(x)
		l1.append(y)
	if x != b and y != b:
		l2.append(x)
		l2.append(y)
l3 = [0] * 300003
for i in range(len(l1)):
	l3[l1[i]] += 1
l4 = [0] * 300003
for i in range(len(l2)):
	l4[l2[i]] += 1
if max(l3) == len(l1) // 2 or len(l2) // 2 == max(l4):
	print('YES')
else:
	print('NO')


def main():
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	pairs = set()
	(x, y) = (None, None)
	for i in range(m):
		pair = input().split(' ')
		x = int(pair[0])
		y = int(pair[1])
		pairs.add((x, y))
	for x in [x, y]:
		if checkx(pairs, x, 0):
			print('YES')
			quit()
	print('NO')

def checkx(pairs: set, target, level):
	d = set((pair for pair in pairs if target in pair))
	rest = pairs - d
	if level == 1:
		return not rest
	if not rest:
		return True
	sample = rest.pop()
	rest.add(sample)
	return checkx(rest, sample[0], 1) or checkx(rest, sample[1], 1)
main()


from collections import Counter

def common(mat):
	p = Counter(mat)
	for j in p:
		if p[j] == len(mat) // 2:
			return j
	return False

def solve(n, m, mat, s):
	c = mat[0][0]
	poc = []
	k = 0
	for j in range(1, m):
		if c not in mat[j]:
			poc.append(mat[j][0])
			poc.append(mat[j][1])
			k = 1
	if k == 0 and c != n:
		return 'YES'
	p = common(poc)
	if p != False and (p > c or c > p):
		return 'YES'
	c = mat[0][1]
	poc = []
	k = 0
	for j in range(1, m):
		if c not in mat[j]:
			poc.append(mat[j][0])
			poc.append(mat[j][1])
			k = 1
	if k == 0 and c != n:
		return 'YES'
	p = common(poc)
	if p != False and (p > c or c > p):
		return 'YES'
	return 'NO'
(n, m) = map(int, input().split())
mat = []
s = set()
for i in range(m):
	(c, d) = sorted(map(int, input().split()))
	s.add(c)
	s.add(d)
	mat.append([c, d])
print(solve(n, m, mat, s))


(n, m) = input().split()
n = int(n)
m = int(m)
l = [[] for i in range(n)]
vals = [[] for i in range(m)]
for i in range(m):
	(temp1, temp2) = input().split()
	temp1 = int(temp1)
	temp2 = int(temp2)
	l[temp1 - 1].append(i)
	l[temp2 - 1].append(i)
	vals[i] = [temp1 - 1, temp2 - 1]
x = list(range(m))
flag = False
one = vals[0][0]
l[one].sort()
okay = False
l[one] = list(set(l[one]))
for i in range(len(l[one])):
	if l[one][i] != x[i]:
		okay = True
		then = x[i]
		break
if len(l[one]) < m:
	if okay == False:
		okay = True
		then = len(l[one])
if okay:
	one1 = vals[then][0]
	one2 = vals[then][1]
	temp = l[one] + l[one1]
	temp.sort()
	temp = list(set(temp))
	if temp == x:
		flag = True
	else:
		temp = l[one] + l[one2]
		temp.sort()
		temp = list(set(temp))
		if temp == x:
			flag = True
if l[one] == x:
	flag = True
if flag == False:
	one = vals[0][1]
	l[one].sort()
	okay = False
	l[one] = list(set(l[one]))
	for i in range(len(l[one])):
		if l[one][i] != x[i]:
			okay = True
			then = x[i]
			break
	if len(l[one]) < m:
		if okay == False:
			okay = True
			then = len(l[one])
	if okay:
		one1 = vals[then][0]
		one2 = vals[then][1]
		temp = l[one] + l[one1]
		temp.sort()
		temp = list(set(temp))
		if temp == x:
			flag = True
		else:
			temp = l[one] + l[one2]
			temp.sort()
			temp = list(set(temp))
			if temp == x:
				flag = True
	if l[one] == x:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ab = [0] * m
for i in range(m):
	(a, b) = map(int, input().split())
	ab[i] = (a, b)
for x in ab[0]:
	d = [0] * n
	all = 0
	for i in range(m):
		(a, b) = (ab[i][0], ab[i][1])
		if a != x and b != x:
			d[a - 1] += 1
			d[b - 1] += 1
			all += 1
	if max(d) == all:
		print('YES')
		exit()
print('NO')


from math import *

def solve():
	(n, m) = [int(x) for x in input().split()]
	k = [0] * n
	pairs = dict()
	for i in range(m):
		(a, b) = [int(x) for x in input().split()]
		k[a - 1] += 1
		k[b - 1] += 1
		if (a, b) in pairs:
			pairs[a, b] += 1
		else:
			pairs[a, b] = 1
	candidates = []
	for i in range(1, n + 1):
		if k[i - 1] >= m / 2:
			candidates += [i]
	for i in candidates:
		for j in range(1, n + 1):
			if i == j:
				continue
			x = k[i - 1]
			y = k[j - 1]
			intersect = pairs.get((i, j), 0) + pairs.get((j, i), 0)
			if x + y - intersect >= m:
				return 'YES'
	return 'NO'
print(solve())


(n, m) = [int(i) for i in input().split()]
l = []
for i in range(m):
	l.append([int(i) for i in input().split()])
done = 0
for x in range(2):
	if done == 0:
		a = l[0][x]
		visited = [0 for i in range(m)]
		visited[0] = 1
		found = 1
		next_round = 0
		for i in range(1, m):
			if l[i][0] == a or l[i][1] == a:
				visited[i] = 1
				found += 1
				continue
			if visited[i] == 0 and next_round == 0:
				next_round = i
		if found >= m:
			print('YES')
			done = 1
		else:
			for tmp in range(2):
				n1 = l[next_round][tmp]
				found1 = 0
				for i in range(m):
					if (l[i][0] == n1 or l[i][1] == n1) and visited[i] == 0:
						found1 += 1
						continue
				if found1 + found >= m:
					print('YES')
					done = 1
					break
if done == 0:
	print('NO')


import collections
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
(x, y) = a.pop()
ans = 'NO'
for v in (x, y):
	val = [0] * (n + 1)
	cnt = 0
	for (v1, v2) in a:
		if v1 != v and v2 != v:
			(val[v1], val[v2], cnt) = (val[v1] + 1, val[v2] + 1, cnt + 1)
	if max(val) == cnt:
		ans = 'YES'
		break
print(ans)


from sys import stdin, stdout

def IsPos(x, y):
	for (xx, yy) in l:
		if xx not in [x, y] and yy not in [x, y]:
			return False
	return True
for _ in range(1):
	(m, n) = list(map(int, stdin.readline().split()))
	l = []
	f = 0
	for i in range(n):
		(A, B) = list(map(int, stdin.readline().split()))
		l += [[A, B]]
	if IsPos(l[0][0], l[0][1]):
		print('YES')
		continue
	x = l[0][0]
	for i in range(1, n):
		if x not in l[i]:
			if IsPos(x, l[i][0]) or IsPos(x, l[i][1]):
				f = 1
			break
	if f:
		print('YES')
		continue
	y = l[0][1]
	for i in range(1, n):
		if y not in l[i]:
			if IsPos(y, l[i][0]) or IsPos(y, l[i][1]):
				f = 1
			break
	print('YES' if f else 'NO')


from collections import Counter
(n, m) = map(int, input().split())
cp = []
for i in range(m):
	cp.append(list(map(int, input().split())))
(v1, v2) = (cp[0][0], cp[0][1])
(m1, m2) = ([], [])
for i in range(1, m):
	if v1 not in cp[i]:
		m1.append(cp[i])
	if v2 not in cp[i]:
		m2.append(cp[i])
used = [[], [], [], []]
if (len(m1) < 2) | (len(m2) < 2):
	print('YES')
else:
	(v1, v2) = (m1[0][0], m1[0][1])
	for i in range(1, len(m1)):
		if v1 not in m1[i]:
			used[0].append(0)
		else:
			used[0].append(1)
		if v2 not in m1[i]:
			used[1].append(0)
		else:
			used[1].append(1)
	(v1, v2) = (m2[0][0], m2[0][1])
	for i in range(1, len(m2)):
		if v1 not in m2[i]:
			used[2].append(0)
		else:
			used[2].append(1)
		if v2 not in m2[i]:
			used[3].append(0)
		else:
			used[3].append(1)
	b = False
	for i in range(4):
		if Counter(used[i])[0] == 0:
			b = True
			break
	if b:
		print('YES')
	else:
		print('NO')


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def get_list():
	return [int(i) for i in input().split()]

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b

def check(m):
	if len(m) <= 1:
		return 1
	s = set(tuple(m[0]))
	for i in m:
		s = s.intersection(tuple(i))
	return len(s) == 1
t = 1
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	l = []
	for i in range(k):
		l.append([int(i) for i in input().split()])
	a = l[0][0]
	if check([i for i in l if a not in i]):
		yn(1)
		continue
	a = l[0][1]
	if check([i for i in l if a not in i]):
		yn(1)
		continue
	yn(0)


(n, m) = map(int, input().split())
my_sets = {}
(no_find, no_find1) = (False, False)
for i in range(m):
	(x, y) = map(int, input().split())
	if x not in my_sets.keys():
		my_sets.update({x: [y]})
	else:
		my_sets[x].append(y)
	if y not in my_sets.keys():
		my_sets.update({y: [x]})
	else:
		my_sets[y].append(x)
val = max(my_sets.items(), key=lambda x: len(x[1]))
my_sets.pop(val[0])
val2 = max(my_sets.items(), key=lambda x: len(x[1]))
remain = m - len(val[1])
remain2 = m - len(val2[1])
if remain:
	for k in my_sets.keys():
		if k != val[0]:
			intrim = list(filter(lambda x: x != val[0], my_sets[k]))
			if len(intrim) == remain:
				no_find = True
				break
	for k in my_sets.keys():
		if k != val2[0]:
			intrim = list(filter(lambda x: x != val2[0], my_sets[k]))
			if len(intrim) == remain2:
				no_find1 = True
				break
	if not no_find and (not no_find1):
		print('No')
	else:
		print('Yes')
else:
	print('Yes')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(m):
	(aa, bb) = list(map(int, input().split()))
	a.append(aa)
	b.append(bb)
cand = [a[0], b[0]]
good = 0
for c in cand:
	rest = 0
	d = {}
	for i in range(m):
		if a[i] == c or b[i] == c:
			continue
		else:
			d[a[i]] = d.get(a[i], 0) + 1
			d[b[i]] = d.get(b[i], 0) + 1
			rest += 1
	if rest == 0:
		good = 1
	for k in d.keys():
		if d[k] == rest:
			good = 1
if good == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().strip().split())
a = input().strip().split()
a = [int(i) for i in a]
b = [a[:]]
flag = 0
for i in range(m - 1):
	(a1, a2) = map(int, input().strip().split())
	b.append([a1, a2])
	if (a1 in a) == False and len(a) < 3 and ((a2 in a) == False):
		a.append(a1)
		a.append(a2)
	if len(a) == 4 and (a1 in a) == False and ((a2 in a) == False):
		flag = 1
if len(a) <= 4 and flag == 0:
	if len(a) == 2:
		print('YES')
	if len(a) == 4:
		s1 = 0
		s2 = 0
		s3 = 0
		s4 = 0
		s5 = 0
		s6 = 0
		for (x, y) in b:
			if x in [a[0], a[1]] or y in [a[0], a[1]]:
				s1 = s1 + 1
			if x in [a[1], a[2]] or y in [a[1], a[2]]:
				s2 = s2 + 1
			if x in [a[2], a[3]] or y in [a[2], a[3]]:
				s3 = s3 + 1
			if x in [a[0], a[2]] or y in [a[0], a[2]]:
				s4 = s4 + 1
			if x in [a[0], a[3]] or y in [a[0], a[3]]:
				s5 = s5 + 1
			if x in [a[1], a[3]] or y in [a[1], a[3]]:
				s6 = s6 + 1
		if s1 == m or s2 == m or s3 == m or (s4 == m) or (s5 == m) or (s6 == m):
			print('YES')
		else:
			print('NO')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
x = []
flag = True
flaga = False
for _ in range(m):
	(a, b) = [int(i) for i in input().split()]
	x.append([a, b])
i = x[0]
for l in range(m):
	if not (x[l][0] in i or x[l][1] in i):
		j = x[l]
		flag = False
		break
if flag:
	flaga = True
else:
	pa = []
	for s in i:
		for d in j:
			pa.append([s, d])
	for s in pa:
		flag = True
		for l in range(m):
			if not (x[l][0] in s or x[l][1] in s):
				j = x[l]
				flag = False
				break
		if flag:
			flaga = True
			break
if flaga:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
fl1 = 0
A = []
B = []
for i in range(m):
	if i != 0:
		(x1, y1) = map(int, input().split())
		if x1 != x and y1 != x:
			A.append([x1, y1])
		if x1 != y and y1 != y:
			B.append([x1, y1])
	else:
		(x, y) = map(int, input().split())
if len(A) != 0:
	x = A[0][0]
	y = A[0][1]
	flx = fly = 0
	for i in range(1, len(A)):
		if A[i][1] != x and A[i][0] != x:
			flx = 1
		if A[i][1] != y and A[i][0] != y:
			fly = 1
	if flx == 0 or fly == 0:
		print('YES')
	elif len(B) != 0:
		x = B[0][0]
		y = B[0][1]
		flx = fly = 0
		for i in range(1, len(B)):
			if B[i][1] != x and B[i][0] != x:
				flx = 1
			if B[i][1] != y and B[i][0] != y:
				fly = 1
		if flx == 0 or fly == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')
else:
	print('YES')


def is_contain(pair, num):
	return pair[0] == num or pair[1] == num
(n, m) = map(int, input().split())
x = [list(map(int, input().split())) for i in range(m)]
ans = False
for i in x[0]:
	cnt = [0] * 300010
	miss = 0
	for pair in x:
		if not is_contain(pair, i):
			cnt[pair[0]] += 1
			cnt[pair[1]] += 1
			miss += 1
	if max(cnt) == miss:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
li1 = []
li2 = []
(xx, yy) = map(int, input().split())
for i in range(m - 1):
	se = set(map(int, input().split()))
	f1 = xx in se
	f2 = yy in se
	if f1 and (not f2):
		li2.append(se.copy())
	elif f2 and (not f1):
		li1.append(se.copy())
	elif f1 and f2:
		continue
	else:
		li1.append(se.copy())
		li2.append(se.copy())
f1 = True
f2 = True
if li1:
	ans = li1[0].copy()
	for i in li1:
		ans = ans.intersection(i)
	if len(ans) == 0:
		f1 = False
if li2:
	ans = li2[0].copy()
	for i in li2:
		ans = ans.intersection(i)
	if len(ans) == 0:
		f2 = False
if f1 or f2:
	print('YES')
else:
	print('NO')


from sys import stdin
(n, m) = list(map(int, stdin.readline().strip().split()))
s = [list(map(int, stdin.readline().strip().split())) for i in range(m)]
(a, b) = (s[0][0], s[0][1])
s1 = []
flag = False
for i in range(len(s)):
	if s[i][0] != a and s[i][1] != a:
		s1.append(s[i])
a1 = 0
b1 = 0
for i in range(len(s1)):
	if i == 0:
		(a1, b1) = (s1[0][0], s1[0][1])
		continue
	if a1 != s1[i][1] and a1 != s1[i][0]:
		a1 = -1
	if b1 != s1[i][1] and b1 != s1[i][0]:
		b1 = -1
if b1 != -1 or a1 != -1:
	flag = True
s1 = []
for i in range(len(s)):
	if s[i][0] != b and s[i][1] != b:
		s1.append(s[i])
a1 = 0
b1 = 0
for i in range(len(s1)):
	if i == 0:
		(a1, b1) = (s1[0][0], s1[0][1])
		continue
	if a1 != s1[i][1] and a1 != s1[i][0]:
		a1 = -1
	if b1 != s1[i][1] and b1 != s1[i][0]:
		b1 = -1
if b1 != -1 or a1 != -1:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
pairs = []
for _ in range(m):
	(a, b) = tuple(map(int, input().split()))
	pairs.append((a, b))

def find_other(x):
	for p in pairs:
		if p[0] != x and p[1] != x:
			return p
	return (-1, -1)

def check(x, y):
	for p in pairs:
		if x not in p and y not in p:
			return False
	return True
p1 = find_other(pairs[0][0])
p2 = find_other(pairs[0][1])
if p1 == (-1, -1) or p2 == (-1, -1):
	print('YES')
	exit()
elif check(pairs[0][0], p1[0]) or check(pairs[0][0], p1[1]) or check(pairs[0][1], p2[0]) or check(pairs[0][1], p2[1]):
	print('YES')
	exit()
else:
	print('NO')


(n, m) = map(int, input().split(' '))
a = []
b = []
for _ in range(m):
	(p, q) = map(int, input().split(' '))
	a.append(p)
	b.append(q)
flag = 0
l1 = []
l2 = []
x = a[0]
for i in range(1, m):
	if a[i] != x and b[i] != x:
		l1.append(a[i])
		l2.append(b[i])
if len(l1) == 0:
	print('YES')
else:
	y = l1[0]
	f1 = 1
	f2 = 1
	for i in range(1, len(l1)):
		if l1[i] != y and l2[i] != y:
			f1 = 0
			break
	y = l2[0]
	for i in range(1, len(l1)):
		if l1[i] != y and l2[i] != y:
			f2 = 0
			break
	if f1 == 1 or f2 == 1:
		flag = 1
	if flag == 1:
		print('YES')
	else:
		x = b[0]
		l1 = []
		l2 = []
		for i in range(1, m):
			if a[i] != x and b[i] != x:
				l1.append(a[i])
				l2.append(b[i])
		y = l1[0]
		f1 = 1
		f2 = 1
		for i in range(1, len(l1)):
			if l1[i] != y and l2[i] != y:
				f1 = 0
				break
		y = l2[0]
		for i in range(1, len(l1)):
			if l1[i] != y and l2[i] != y:
				f2 = 0
				break
		if f1 == 1 or f2 == 1:
			flag = 1
		if flag == 1:
			print('YES')
		else:
			print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
a = []
for i in range(0, m):
	b = input().split()
	b[0] = int(b[0])
	b[1] = int(b[1])
	a.append(b[0])
	a.append(b[1])
d = [0] * (n + 1)
cnt = 0
for i in range(0, m):
	if a[i * 2] != a[0] and a[i * 2 + 1] != a[0]:
		d[a[i * 2 + 1]] += 1
		d[a[i * 2]] += 1
		cnt += 1
if cnt == 0:
	print('YES')
	exit(0)
if max(d) == cnt:
	print('YES')
	exit(0)
d = [0] * (n + 1)
cnt = 0
for i in range(0, m):
	if a[i * 2] != a[1] and a[i * 2 + 1] != a[1]:
		d[a[i * 2 + 1]] += 1
		d[a[i * 2]] += 1
		cnt += 1
if cnt == 0:
	print('YES')
	exit(0)
if max(d) == cnt:
	print('YES')
	exit(0)
print('NO')


import sys

def check(ans, ind, M):
	for i in range(ind, m):
		if ans in M[i]:
			continue
		else:
			return i
	return i + 1
(n, m) = map(int, input().split())
M = []
if m <= 2:
	print('YES')
	sys.exit(0)
for i in range(m):
	(x, y) = map(int, input().split())
	M.append([x, y])
for j in M[0]:
	n_ind = check(j, 1, M)
	if n_ind == m:
		print('YES')
		sys.exit(0)
	else:
		for k in M[n_ind]:
			for l in range(n_ind, m):
				if j in M[l] or k in M[l]:
					if l == m - 1:
						print('YES')
						sys.exit(0)
				else:
					break
print('NO')


(n, m) = map(int, input().split())
(x1, x2) = map(int, input().split())
A = []
B = []
z1 = True
z2 = True
z = True
for i in range(m - 1):
	(a, b) = map(int, input().split())
	if x1 not in {a, b}:
		A.append({a, b})
	if x2 not in {a, b}:
		B.append({a, b})
if len(A) > 1:
	s1 = A[0] & A[1]
	if s1 != {}:
		for i in range(2, len(A)):
			if len(s1 & (A[i] & A[i - 1])) != 0:
				pass
			else:
				z1 = False
				break
	else:
		z1 = False
else:
	z = False
	print('Yes')
if z:
	if len(B) > 1:
		s2 = B[0] & B[1]
		if s2 != {}:
			for i in range(2, len(B)):
				if len(s2 & (B[i] & B[i - 1])) != 0:
					pass
				else:
					z2 = False
					break
		if z1 or z2:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')


(n, m) = map(int, input().split())
pairs = set()
for i in range(m):
	pairs.add(tuple(map(int, input().split())))
first = pairs.pop()
x = first[0]
copy = pairs.copy()
for el in pairs:
	if x in el:
		copy.remove(el)
if len(copy) == 0:
	print('YES')
	exit(0)
second = copy.pop()
y = second[0]
p = 0
for el in copy:
	if y not in el:
		p = 1
		break
if p == 0:
	print('YES')
	exit(0)
y = second[1]
p = 0
for el in copy:
	if y not in el:
		p = 1
		break
if p == 0:
	print('YES')
	exit(0)
x = first[1]
copy = pairs.copy()
for el in pairs:
	if x in el:
		copy.remove(el)
if len(copy) == 0:
	print('YES')
	exit(0)
pairs.add(second)
second = pairs.pop()
y = second[0]
p = 0
for el in copy:
	if y not in el:
		p = 1
if p == 0:
	print('YES')
	exit(0)
y = second[1]
p = 0
for el in copy:
	if y not in el:
		p = 1
if p == 0:
	print('YES')
	exit(0)
print('NO')


def get(list):
	for z in range(2):
		x = list[0][z]
		for i in range(m):
			if x not in list[i]:
				break
		else:
			return 0
		for w in range(2):
			y = list[i][w]
			for j in range(m):
				if x not in list[j] and y not in list[j]:
					break
			else:
				return 0
	return 1
(n, m) = map(int, input().split())
l = []
for i in range(m):
	l.append(list(map(int, input().strip().split())))
if get(l) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(m):
	(u, v) = map(int, input().split())
	d = [u, v]
	a.append(d)
for i in a[0]:
	d = [0] * (n + 1)
	c = 0
	for j in range(1, m):
		if i not in a[j]:
			d[a[j][1]] += 1
			d[a[j][0]] += 1
			c += 1
	if c == max(d):
		exit(print('YES'))
print('NO')


(n, m) = map(int, input().split())
arr = []
for _ in range(m):
	(a, b) = map(int, input().split())
	arr.append([a, b])
x = []
y1 = None
y2 = None
y = None
temp1 = arr[0]
x.append(temp1[0])
x.append(temp1[1])
ans = []
flag = True
for i in x:
	temp = 1
	index = []
	flag = True
	y = None
	y1 = None
	y2 = None
	for (j, k) in arr:
		if i != j and i != k:
			if y == None:
				y1 = j
				y2 = k
				y = j
				index = [j, k]
			elif y != j and y != k and (temp > 0):
				y = y2
				l = arr.index(index)
				r = arr.index([j, k])
				for p in range(l, r + 1):
					temp1 = arr[p]
					if y != temp1[0] and y != temp1[1] and (i != temp1[0]) and temp1[1]:
						flag = False
				temp -= 1
			elif temp <= 0:
				if y != j and y != k:
					flag = False
	ans.append(flag)
	if flag:
		break
if any([x for x in ans]) or flag:
	print('YES')
else:
	print('NO')


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(m, n) = gil()
p = []
for _ in range(n):
	p.append(gil())

def getLeft(x, it):
	left = []
	for i in it:
		if x not in p[i]:
			left.append(i)
	return left
left1 = getLeft(p[0][0], range(n))
if len(left1) > 1:
	(x, y) = p[left1[0]]
	if getLeft(x, left1) == [] or getLeft(y, left1) == []:
		print('YES')
		exit()
else:
	print('YES')
	exit()
left2 = getLeft(p[0][1], range(n))
if len(left2) > 1:
	(x, y) = p[left2[0]]
	if getLeft(x, left2) == [] or getLeft(y, left2) == []:
		print('YES')
		exit()
else:
	print('YES')
	exit()
print('NO')


[N, M] = list(map(int, input().split()))
listi = []
for i in range(M):
	listi.append([int(i) for i in input().split()])
for x in listi[0]:
	array = N * [0]
	AlPr = 0
	for y in range(1, M):
		if listi[y][0] != x and listi[y][1] != x and (listi[y][0] == listi[y][1]):
			array[listi[y][0] - 1] += 1
			AlPr += 1
		elif listi[y][0] != x and listi[y][1] != x and (listi[y][0] != listi[y][1]):
			array[listi[y][0] - 1] += 1
			array[listi[y][1] - 1] += 1
			AlPr += 1
	if max(array) == AlPr:
		print('YES')
		exit()
print('NO')


from sys import stdin
from sys import stdout
(n, m) = map(int, stdin.readline().split())
pairs = []
flag = 0
for i in range(m):
	(u, v) = map(int, stdin.readline().split())
	pairs.append((u, v))
for i in pairs[0]:
	cnt = 0
	val = [0] * (n + 1)
	for p in pairs:
		if p[0] != i and p[1] != i:
			val[p[0]] += 1
			val[p[1]] += 1
			cnt += 1
	if cnt in val:
		flag = 1
		break
if flag == 1:
	stdout.write('YES')
else:
	stdout.write('NO')


nm = list(map(int, input().split()))
l = []
flag = 0
for i in range(0, nm[1]):
	k = list(map(int, input().split()))
	l.append(k)
for j in range(2):
	x = l[0][j]
	d = [0] * 300001
	c = 0
	for i in l:
		if i[0] != x and i[1] != x:
			d[i[0]] += 1
			d[i[1]] += 1
		else:
			c += 1
	if max(d) == nm[1] - c:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


test = list(map(int, input().split(' ')))
n = test[0]
m = test[1]
x1 = 0
x2 = 0
y1 = 0
y2 = 0
t = list(map(int, input().split(' ')))
x1 = t[0]
y1 = t[1]
q1 = []
a = []
a.append(t)
for i in range(m - 1):
	t = list(map(int, input().split(' ')))
	a.append(t)
	if x1 not in t:
		q1.append(t)
k = 1
if len(q1) > 0:
	x2 = q1[0][0]
	y2 = q1[0][1]
	for i in range(1, len(q1)):
		if x2 not in q1[i]:
			k = 0
			break
	if k == 1:
		print('YES')
		exit()
	k = 1
	for i in range(1, len(q1)):
		if y2 not in q1[i]:
			k = 0
			break
	if k == 1:
		print('YES')
		exit()
	k = 1
q1 = []
for i in range(1, m):
	if y1 not in a[i]:
		q1.append(a[i])
if len(q1) > 0:
	x2 = q1[0][0]
	y2 = q1[0][1]
	for i in range(1, len(q1)):
		if x2 not in q1[i]:
			k = 0
			break
	if k == 1:
		print('YES')
		exit()
	k = 1
	for i in range(1, len(q1)):
		if y2 not in q1[i]:
			k = 0
			break
if k == 1:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
pairs = []
for i in range(m):
	a = [int(x) for x in input().split()]
	pairs.append(a)
(x, y) = (pairs[0][0], pairs[0][1])
for item in pairs:
	if item[0] != x and item[0] != y and (item[1] != x) and (item[1] != y):
		(a, b, c, d) = (x, y, item[0], item[1])
		break
else:
	(a, b, c, d) = (x, y, x, y)
for (x, y) in ((a, b), (a, c), (b, d), (c, d), (a, d), (b, c)):
	for item in pairs:
		if item[0] != x and item[1] != x and (item[0] != y) and (item[1] != y):
			break
	else:
		print('YES')
		break
else:
	print('NO')


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()

def main():
	(n, m) = get_ints()
	arr = [0] * m
	for i in range(m):
		(a, b) = get_ints()
		arr[i] = (a, b)
	x = arr[0][0]
	flag = True
	ind = 0
	for i in range(m):
		if x not in arr[i]:
			flag = False
			ind = i
			y = arr[i][0]
			break
	if flag:
		print('YES')
		return
	flag = True
	for i in range(ind, m):
		if y not in arr[i] and x not in arr[i]:
			flag = False
			break
	if flag:
		print('YES')
		return
	y = arr[ind][1]
	flag = True
	for i in range(ind, m):
		if y not in arr[i] and x not in arr[i]:
			flag = False
			break
	if flag:
		print('YES')
		return
	x = arr[0][1]
	flag = True
	ind = 0
	for i in range(m):
		if x not in arr[i]:
			flag = False
			ind = i
			y = arr[i][0]
			break
	if flag:
		print('YES')
		return
	flag = True
	for i in range(ind, m):
		if y not in arr[i] and x not in arr[i]:
			flag = False
			break
	if flag:
		print('YES')
		return
	y = arr[ind][1]
	flag = True
	for i in range(ind, m):
		if y not in arr[i] and x not in arr[i]:
			flag = False
			break
	if flag:
		print('YES')
		return
	print('NO')
main()


def check(ch1, ch2):
	flag = True
	for pair in pairs:
		if ch1 not in pair and ch2 not in pair:
			flag = False
	return flag
(n, m) = map(int, input().strip().split())
a = []
pairs = []
for j in range(n + 1):
	a.append([])
for i in range(m):
	(x, y) = map(int, input().strip().split())
	pairs.append((x, y))
w = pairs[0][0]
y = pairs[0][1]
e = ' '
r = ' '
for pair in pairs:
	if w not in pair and y not in pair:
		e = pair[0]
		r = pair[1]
		break
if check(w, e) or check(w, r) or check(y, e) or check(y, r) or check(w, y):
	print('YES')
else:
	print('NO')


def check(ls, cand):
	for i in ls:
		if not i[0] in cand and (not i[1] in cand):
			return False
	return True
(n, m) = map(int, input().split())
ls = []
for i in range(m):
	ls.append(tuple(map(int, input().split())))
inter = set(range(1, n + 1))
for i in ls:
	inter = inter.intersection(i)
if len(inter) >= 1:
	print('YES')
else:
	first = ls[0]
	for i in ls:
		if len(set(first).intersection(set(i))) == 0:
			second = i
			break
	else:
		print('YES')
		exit()
	cand = [(first[0], second[0]), (first[0], second[1]), (first[1], second[0]), (first[1], second[1])]
	for i in cand:
		if check(ls, i):
			print('YES')
			break
	else:
		print('NO')


(n, m) = map(int, input().split())
alt_c1 = 0
alt_c2 = 0
vals_1 = [0] * (n + 1)
vals_2 = [0] * (n + 1)
(a, b) = map(int, input().split())
for i in range(m - 1):
	(ai, bi) = map(int, input().split())
	if ai != a and bi != a:
		vals_1[ai] += 1
		vals_1[bi] += 1
		alt_c1 += 1
	if ai != b and bi != b:
		vals_2[ai] += 1
		vals_2[bi] += 1
		alt_c2 += 1
if max(vals_1) == alt_c1 or max(vals_2) == alt_c2:
	print('YES')
	exit()
print('NO')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
g = [I() for i in range(m)]
(x, y) = g[0]
tf = 0
for i in [x, y]:
	temp = 0
	f = [0] * (n + 1)
	for j in g:
		if i not in j:
			temp += 1
			f[j[0]] += 1
			f[j[1]] += 1
	if temp == max(f):
		tf = 1
		break
print('YES' if tf else 'NO')


import sys
import math
from itertools import permutations
input = sys.stdin.readline
(n, m) = map(int, input().split())
arr = []
for i in range(m):
	(a, b) = map(int, input().split())
	if a > b:
		arr.append((b, a))
	else:
		arr.append((a, b))
flag1 = False
flag2 = False
flag3 = False
flag4 = False
flag5 = False
flag6 = False
cur = 0
for i in range(1, m):
	if arr[0][0] not in arr[i]:
		cur = i
		flag1 = True
		break
if flag1:
	for i in range(cur + 1, m):
		if arr[cur][0] not in arr[i] and arr[0][0] not in arr[i]:
			flag2 = True
			break
	if flag2:
		for i in range(cur + 1, m):
			if arr[cur][1] not in arr[i] and arr[0][0] not in arr[i]:
				flag3 = True
				break
		if flag3:
			for i in range(1, m):
				if arr[0][1] not in arr[i]:
					cur = i
					flag4 = True
					break
			if flag4:
				for i in range(cur + 1, m):
					if arr[cur][0] not in arr[i] and arr[0][1] not in arr[i]:
						flag5 = True
						break
				if flag5:
					for i in range(cur + 1, m):
						if arr[cur][1] not in arr[i] and arr[0][1] not in arr[i]:
							flag6 = True
							break
					if flag6:
						print('NO')
					else:
						print('YES')
				else:
					print('YES')
			else:
				print('YES')
		else:
			print('YES')
	else:
		print('YES')
else:
	print('YES')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]
(a0, b0) = (ab[0][0], ab[0][1])
for (ai, bi) in ab[1:]:
	if len({a0, ai, b0, bi}) == 4:
		cands = [(a0, ai), (a0, bi), (b0, ai), (b0, bi)]
		break
else:
	print('Yes')
	exit()
for (x, y) in cands:
	for (ai, bi) in ab:
		if ai != x and bi != x and (ai != y) and (bi != y):
			break
	else:
		print('Yes')
		break
else:
	print('No')


def covers_all(a1, b1):
	for i in d:
		if a1 not in i and b1 not in i:
			return False
	return True
(n, m) = map(int, input().strip().split())
d = {}
pair_found = False
pairs = []
for i in range(m):
	(a, b) = map(int, input().strip().split())
	if (a, b) not in d:
		d[a, b] = 1
		pairs.append((a, b))
	if i == 0:
		n1 = a
		n2 = b
	elif pair_found == False and n1 not in [a, b] and (n2 not in [a, b]):
		n3 = a
		n4 = b
		pair_found = True
if pair_found == False or covers_all(n1, n3) or covers_all(n1, n4) or covers_all(n2, n3) or covers_all(n2, n4):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bigList = []
for i in range(m):
	subList = []
	(a, b) = map(int, input().split())
	subList.append(a)
	subList.append(b)
	bigList.append(subList)
retList = []
x = bigList[0][0]
for i in range(1, m):
	if x not in bigList[i]:
		y = bigList[i][0]
		break
for j in range(1, m):
	if x not in bigList[j] and y not in bigList[j]:
		retList.append(0)
		break
for i in range(1, m):
	if x not in bigList[i]:
		y = bigList[i][1]
		break
for j in range(1, m):
	if x not in bigList[j] and y not in bigList[j]:
		retList.append(0)
		break
x = bigList[0][1]
for i in range(1, m):
	if x not in bigList[i]:
		y = bigList[i][0]
		break
for j in range(1, m):
	if x not in bigList[j] and y not in bigList[j]:
		retList.append(0)
		break
for i in range(1, m):
	if x not in bigList[i]:
		y = bigList[i][1]
		break
for j in range(1, m):
	if x not in bigList[j] and y not in bigList[j]:
		retList.append(0)
		break
if len(retList) < 4:
	print('YES')
else:
	print('NO')


(n, m) = tuple([int(i) for i in input().split()])
list_couple = []
for i in range(m):
	list_couple.append(tuple([int(i) for i in input().split()]))
flg = 0
for x in list_couple[0]:
	list_y = list(filter(lambda x1: x1[0] != x and x1[1] != x, list_couple))
	if list_y == []:
		flg = 1
		break
	for y in list_y[0]:
		list_ = list(filter(lambda x1: x1[0] != y and x1[1] != y, list_y))
		if list_ == []:
			flg = 1
if flg:
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
pairs = []
for i in range(m):
	(a, b) = map(int, input().split())
	pairs.append([a, b])
d = {}
px = pairs[0][0]
px2 = pairs[0][1]
for x in [px, px2]:
	remain = []
	count = 0
	for j in pairs:
		if j[0] == x or j[1] == x:
			continue
		else:
			remain.append(j)
			count += 1
	d = {}
	if count == 0:
		print('YES')
		sys.exit()
	for j in remain:
		d[j[0]] = d.get(j[0], 0) + 1
		d[j[1]] = d.get(j[1], 0) + 1
	for i in d.values():
		if i == count:
			print('YES')
			sys.exit()
print('NO')


iarr = list(map(int, input().split()))
n = iarr[0]
m = iarr[1]
arr = [0 for i in range(n + 1)]
xar = [0 for i in range(m)]
yar = [0 for i in range(m)]
for i in range(m):
	iarr = list(map(int, input().split()))
	x = iarr[0]
	y = iarr[1]
	xar[i] = x
	yar[i] = y
	arr[x] += 1
	arr[y] += 1
flag = 0
for x in range(1, n + 1):
	fx = arr[x]
	if fx >= m // 2:
		sfarr = [0 for i in range(n + 1)]
		for j in range(m):
			if xar[j] != x and yar[j] != x:
				sfarr[xar[j]] += 1
				sfarr[yar[j]] += 1
		for j in range(1, n + 1):
			if sfarr[j] == m - fx:
				flag = 1
				break
if flag == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from math import *

def tryxy(x, y):
	global n, m, a, b
	for i in range(m):
		if not (a[i] == x or b[i] == x or a[i] == y or (b[i] == y)):
			return False
	return True

def tryx(x):
	global n, m, a, b
	y = None
	for i in range(m):
		if a[i] == x or b[i] == x:
			continue
		elif tryxy(x, a[i]) == True or tryxy(x, b[i]) == True:
			return True
		else:
			return False
	return True

def main():
	global n, m, a, b
	(n, m) = [int(x) for x in stdin.readline().split()]
	a = [0] * m
	b = [0] * m
	for i in range(m):
		(a[i], b[i]) = [int(x) for x in stdin.readline().split()]
	if tryx(a[0]) or tryx(b[0]):
		stdout.write('YES')
	else:
		stdout.write('NO')
	return 0
main()


def main():

	def check(x, y):
		for (a, b) in mas:
			if not ((a == x or a == y) or (b == x or b == y)):
				return [a, b]
		return [-1, -1]

	def check1(x, y):
		for (a, b) in mas:
			if not ((a == x or a == y) or (b == x or b == y)):
				return False
		return True
	(n, m) = list(map(int, input().split()))
	mas = []
	ans = False
	for i in range(m):
		mas.append(sorted(list(map(int, input().split()))))
	k = check(*mas[0])
	if k == [-1, -1]:
		print('YES')
	else:
		ans = check1(mas[0][0], k[0]) or check1(mas[0][0], k[1]) or check1(mas[0][1], k[0]) or check1(mas[0][1], k[1])
		if ans:
			print('YES')
		else:
			print('NO')
main()


nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
pairs = []
for i in range(m):
	ab = input().split(' ')
	a = int(ab[0])
	b = int(ab[1])
	pairs.append((a, b))
x1 = pairs[0][0]
others = []
for i in range(1, m):
	if pairs[i][0] == x1 or pairs[i][1] == x1:
		continue
	else:
		others.append(pairs[i])
carr = [0 for i in range(n)]
for i in range(len(others)):
	carr[others[i][0] - 1] += 1
	carr[others[i][1] - 1] += 1
if max(carr) == len(others):
	print('YES')
	exit()
x2 = pairs[0][1]
others = []
for i in range(1, m):
	if pairs[i][0] == x2 or pairs[i][1] == x2:
		continue
	else:
		others.append(pairs[i])
carr = [0 for i in range(n)]
for i in range(len(others)):
	carr[others[i][0] - 1] += 1
	carr[others[i][1] - 1] += 1
if max(carr) == len(others):
	print('YES')
	exit()
print('NO')


(n, m) = map(int, input().split())
s = {}
st = False
for i in range(m):
	(x, y) = map(int, input().split())
	if i == 0:
		xx = x
		yy = y
	elif st == False:
		if yy not in [x, y] and xx not in [x, y]:
			xx2 = x
			yy2 = y
			st = True
	try:
		s[x].add(i)
	except:
		s[x] = set([i])
	try:
		s[y].add(i)
	except:
		s[y] = set([i])
stt = 'NO'
k = set(list(range(0, m)))
arr = [xx, yy]
if st:
	arr.extend([xx2, yy2])
for i in arr:
	if len(s[i]) >= m / 2:
		for ii in arr:
			if i == ii:
				continue
			if len(s[ii]) >= m - len(s[i]):
				if s[ii].union(s[i]) == k:
					stt = 'YES'
					break
print(stt)


from collections import defaultdict
(n, m) = map(int, input().split(' '))
a = [None for i in range(m)]
for i in range(m):
	(x, y) = map(int, input().split(' '))
	a[i] = [x, y]

def check(x):
	counter = defaultdict(int)
	last_pair = None
	unbound_count = 0
	for i in range(m):
		if a[i][0] != x and a[i][1] != x:
			unbound_count += 1
			counter[a[i][0]] += 1
			counter[a[i][1]] += 1
			last_pair = a[i]
	if unbound_count == 0:
		return True
	return counter[last_pair[0]] == unbound_count or counter[last_pair[1]] == unbound_count
for x in a[0]:
	if check(x):
		print('YES')
		exit(0)
print('NO')


(n, m) = map(int, input().split())
aa = []
for i in range(m):
	(a, b) = map(int, input().split())
	aa.append((a, b))
for i in aa[0]:
	d = {0: 0}
	y = 0
	for j in aa:
		if i not in j:
			y += 1
			if j[0] not in d:
				d[j[0]] = 1
			else:
				d[j[0]] += 1
			if j[1] not in d:
				d[j[1]] = 1
			else:
				d[j[1]] += 1
	if y == max(d.values()):
		print('YES')
		exit()
print('NO')


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def computeLPSArray(pat, M, lps):
	len = 0
	lps[0]
	i = 1
	while i < M:
		if pat[i] == pat[len]:
			len += 1
			lps[i] = len
			i += 1
		elif len != 0:
			len = lps[len - 1]
		else:
			lps[i] = 0
			i += 1
t = 1
while t:
	t -= 1
	(n, m) = map(int, fastinput().split())
	a = []
	for _ in range(m):
		a.append(list(map(int, fastinput().split())))
	x1 = a[0][0]
	y1 = a[0][1]
	y2 = a[0][1]
	for i in a:
		if i[0] == x1 or i[1] == x1:
			continue
		else:
			y1 = i[0]
			y2 = i[1]
			break
	x2 = a[0][1]
	y3 = a[0][0]
	y4 = a[0][0]
	for i in a:
		if i[0] == x2 or i[1] == x2:
			continue
		else:
			y3 = i[0]
			y4 = i[1]
			break

	def istrue(x, y):
		for i in a:
			if i[0] == x or i[0] == y or i[1] == x or (i[1] == y):
				continue
			else:
				return False
		return True
	if istrue(x1, y1) or istrue(x1, y2) or istrue(x2, y3) or istrue(x2, y4):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
li = []
for _ in range(m):
	(a, b) = map(int, input().split())
	li.append([a, b])
for x in li[0]:
	dic = {-1: 0}
	all = 0
	for c in li:
		if c[0] != x and c[1] != x:
			dic[c[0]] = dic[c[0]] + 1 if dic.get(c[0]) else 1
			dic[c[1]] = dic[c[1]] + 1 if dic.get(c[1]) else 1
			all += 1
	if dic[max(dic, key=dic.__getitem__)] == all:
		print('YES')
		exit(0)
print('NO')


import itertools
(n, m) = map(int, input().split())
D = []
for i in range(m):
	(a, b) = map(int, input().split())
	D.append((a, b))
d = []
for i in range(m):
	(a, b) = D[i]
	if len(d) == 0:
		d.append(a)
		d.append(b)
	elif a not in d and b not in d:
		d.append(a)
		d.append(b)
		break
R = [i for i in range(len(d))]
for (i, j) in itertools.combinations(R, 2):
	(a, b) = (d[i], d[j])
	for k in range(m):
		(a1, b1) = D[k]
		if a1 != a and a1 != b and (b1 != a) and (b1 != b):
			break
	else:
		print('YES')
		exit()
print('NO')


def isY(x):
	possible_ys = []
	xc = 0
	for p in ab:
		if x in p:
			xc += 1
		elif len(possible_ys) == 0:
			possible_ys = p
	if len(possible_ys) == 0:
		return True
	for py in possible_ys:
		yc = 0
		for p in ab:
			if x not in p and py in p:
				yc += 1
		if xc + yc == len(ab):
			return True
	return False
(n, m) = list(map(int, input().split()))
ab = []
for i in range(m):
	inp = input()
	ab.append(list(map(int, inp.split())))
valid = False
first = ab[0]
print('YES' if isY(first[0]) or isY(first[1]) else 'NO')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(m)]
CANDI = [[0, 0] for i in range(4)]
x = AB[0][0]
y = AB[0][1]
for (a, b) in AB:
	if a == x or b == x:
		continue
	else:
		x1 = a
		x2 = b
		break
else:
	print('YES')
	sys.exit()
for (a, b) in AB:
	if a == y or b == y:
		continue
	else:
		y1 = a
		y2 = b
		break
else:
	print('YES')
	sys.exit()
for (z, w) in [[x, x1], [x, x2], [y, y1], [y, y2]]:
	for (a, b) in AB:
		if a == z or b == z or a == w or (b == w):
			continue
		else:
			break
	else:
		print('YES')
		sys.exit()
print('NO')


class Node:

	def __init__(self, data):
		self.left = None
		self.right = None
		self.data = data

	def add_left(self, data):
		self.left = data

	def add_right(self, data):
		self.right = data
(n, m) = [int(x) for x in input().strip().split()]
(u, v) = [int(x) for x in input().strip().split()]
tree1 = Node(u)
tree2 = Node(v)
dic1 = {}
dic1[u] = 1
dic2 = {}
dic3 = {}
dic3[u] = 1
dic4 = {}
dic4[v] = 1
dic2[v] = 1
count1 = 0
count2 = 0
count3 = 0
count4 = 0
for _ in range(m - 1):
	(u, v) = [int(x) for x in input().strip().split()]
	if u not in dic1 and v not in dic1:
		tree1.add_left(u)
		dic1[u] = 1
		count1 += 1
	if u not in dic3 and v not in dic3:
		tree1.add_right(v)
		dic3[v] = 1
		count2 += 1
	if u not in dic2 and v not in dic2:
		tree2.add_left(u)
		dic2[u] = 1
		count3 += 1
	if u not in dic4 and v not in dic4:
		tree2.add_right(v)
		dic4[v] = 1
		count4 += 1
res = min(count1, count2, count3, count4)
if res > 1:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split()))
if m < 3:
	print('YES')
else:
	arr = []
	for i in range(m):
		arr2 = list(map(int, input().split()))
		arr.append(arr2)
	f1 = arr[0][0]
	f2 = arr[0][1]
	ans = True
	num = f1
	aaa = []
	for pair in arr:
		if not num in pair and len(aaa) == 0:
			aaa.append(pair[0])
			aaa.append(pair[1])
		elif len(aaa) == 1 and (not num in pair):
			if not aaa[0] in pair:
				ans = False
		elif len(aaa) == 2 and (not num in pair):
			if aaa[0] in pair and aaa[1] not in pair:
				del aaa[1]
			if len(aaa) == 2:
				if aaa[1] in pair and aaa[0] not in pair:
					del aaa[0]
			if len(aaa) == 1:
				if not aaa[0] in pair:
					ans = False
			if len(aaa) == 2:
				if not (aaa[0] in pair or aaa[1] in pair):
					ans = False
	ans2 = True
	num = f2
	aaa = []
	for pair in arr:
		if not num in pair and len(aaa) == 0:
			aaa.append(pair[0])
			aaa.append(pair[1])
		elif len(aaa) == 1 and (not num in pair):
			if not aaa[0] in pair:
				ans2 = False
		elif len(aaa) == 2 and (not num in pair):
			if aaa[0] in pair and aaa[1] not in pair:
				del aaa[1]
			if len(aaa) == 2:
				if aaa[1] in pair and aaa[0] not in pair:
					del aaa[0]
			if len(aaa) == 1:
				if not aaa[0] in pair:
					ans2 = False
			if len(aaa) == 2:
				if not (aaa[0] in pair or aaa[1] in pair):
					ans2 = False
	if ans or ans2:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(m):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
g = {}
ai = a[0]
bi = b[0]
counter = 0
for i in range(m):
	if ai != a[i] and ai != b[i]:
		if a[i] in g:
			g[a[i]] += 1
		else:
			g[a[i]] = 1
		if b[i] in g:
			g[b[i]] += 1
		else:
			g[b[i]] = 1
	else:
		counter += 1
flag = False
if counter == m:
	flag = True
for i in g:
	if g[i] == m - counter:
		flag = True
		break
if flag != True:
	g = {}
	counter = 0
	for i in range(m):
		if bi != a[i] and bi != b[i]:
			if a[i] in g:
				g[a[i]] += 1
			else:
				g[a[i]] = 1
			if b[i] in g:
				g[b[i]] += 1
			else:
				g[b[i]] = 1
		else:
			counter += 1
	for i in g:
		if g[i] == m - counter:
			flag = True
			break
if flag == True:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
if m <= 2:
	print('YES')
	exit()
a = []
for i in range(m):
	a.append(sorted(tuple(map(int, input().split()))))
x1 = a[0][0]
x2 = a[0][1]
x3 = -1
x4 = -1
for i in a:
	if i[0] == x1 or i[0] == x2:
		continue
	if i[1] == x1 or i[1] == x2:
		continue
	x3 = i[0]
	x4 = i[1]
	break
if x4 == -1:
	print('YES')
	exit()
c = []
c.append({x1, x2})
c.append({x1, x3})
c.append({x1, x4})
c.append({x2, x3})
c.append({x2, x4})
c.append({x3, x4})
f = []
f.append(True)
f.append(True)
f.append(True)
f.append(True)
f.append(True)
f.append(True)
for i in a:
	(x, y) = i
	for j in range(6):
		if x not in c[j] and y not in c[j]:
			f[j] = False
ans = False
for i in f:
	ans |= i
if ans:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
from operator import itemgetter
(N, M) = map(int, input().split())
A = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]
B = [[] for _ in range(N)]
for (i, (a1, a2)) in enumerate(A):
	B[a1].append(i)
	B[a2].append(i)

def check(x1, x2):
	for a in A:
		if not x1 in a and (not x2 in a):
			return False
	return True
C = []
for i in range(N):
	C.append((i, len(B[i])))
C.sort(reverse=True, key=itemgetter(1))
n1 = C[0][0]
ans = 'NO'
if len(B[n1]) == M:
	ans = 'YES'
else:
	to_check = [True] * M
	for i in B[n1]:
		to_check[i] = False
	for m in range(M):
		if to_check[m]:
			(a1, a2) = A[m]
			break
	if check(n1, a1):
		ans = 'YES'
	if check(n1, a2):
		ans = 'YES'
	i = B[n1][0]
	for k in A[i]:
		if k != n1:
			n2 = k
	to_check = [True] * M
	for i in B[n2]:
		to_check[i] = False
	for m in range(M):
		if to_check[m]:
			(a1, a2) = A[m]
			break
	if check(n2, a1):
		ans = 'YES'
	if check(n2, a2):
		ans = 'YES'
print(ans)


from sys import stdin, stdout

def find_union_universal_vertex(edges) -> str:

	def edge_to_x_or_y(x: int, y: int) -> bool:
		for edge in edges:
			if edge[0] != x and edge[0] != y and (edge[1] != x) and (edge[1] != y):
				return False
		return True
	for x in edges[0]:
		if edge_to_x_or_y(x, 0):
			return 'YES'
		for edge in edges:
			if edge[0] != x and edge[1] != x:
				if edge_to_x_or_y(x, edge[0]) or edge_to_x_or_y(x, edge[1]):
					return 'YES'
				break
	return 'NO'
(value_upperbound, n) = map(int, stdin.readline().rstrip().split(' '))
pairs = []
for _ in range(n):
	pairs.append(stdin.readline().rstrip().split(' '))
stdout.write(find_union_universal_vertex(pairs) + '\n')


(n, m) = map(int, input().split())
a = []
b = []
x = 0
y = 0
for i in range(m):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
x = a[0]
y = 0
ans = 1
fa = 1
fb = 1
fc = 1
fd = 1
if m == 1:
	print('YES')
	quit()
for i in range(1, m):
	if a[i] != x and a[i] != y and (b[i] != x) and (b[i] != y):
		y = a[i]
		for j in range(i + 1, m):
			if a[j] != x and a[j] != y and (b[j] != x) and (b[j] != y):
				fa = 0
		if fa == 1:
			print('YES')
			quit()
		y = b[i]
		for j in range(0, m):
			if a[j] != x and a[j] != y and (b[j] != x) and (b[j] != y):
				fb = 0
		if fb == 1:
			print('YES')
			quit()
		break
	if i + 1 == m:
		print('YES')
		quit()
x = b[0]
for i in range(1, m):
	if a[i] != x and a[i] != y and (b[i] != x) and (b[i] != y):
		y = a[i]
		for j in range(0, m):
			if a[j] != x and a[j] != y and (b[j] != x) and (b[j] != y):
				fc = 0
		if fc == 1:
			print('YES')
			quit()
		y = b[i]
		for j in range(0, m):
			if a[j] != x and a[j] != y and (b[j] != x) and (b[j] != y):
				fd = 0
		if fd == 1:
			print('YES')
			quit()
		break
	if i + 1 == m:
		print('YES')
		quit()
print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import *
from collections import deque
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0:
		return False
	if n < 9:
		return True
	if n % 3 == 0:
		return False
	r = int(n ** 0.5)
	f = 5
	while f <= r:
		if n % f == 0:
			return False
		if n % (f + 2) == 0:
			return False
		f += 6
	return True

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans
vis = []
graph = []

def dfs(v):
	if vis[v]:
		return 0
	vis[v] = True
	temp = 0
	for vv in graph[v]:
		temp += dfs(vv)
	return 1 + temp

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
(n, m) = map(int, input().split())
mat = []
for i in range(m):
	(x, y) = map(int, input().split())
	mat.append([x - 1, y - 1])
temp = [mat[0][0], mat[0][1]]
for i in temp:
	l = [0 for j in range(n)]
	no = 0
	for j in range(m):
		if mat[j][0] != i and mat[j][1] != i:
			no += 1
			l[mat[j][0]] += 1
			l[mat[j][1]] += 1
	if no <= max(l):
		print('YES')
		break
else:
	print('NO')


(n, m) = (int(i) for i in input().split())
(x1, x2) = (int(i) for i in input().split())
y1 = None
y2 = None
y3 = None
y4 = None
for i in range(1, m):
	pair = [int(i) for i in input().split()]
	if x1 is not False:
		if x1 not in pair:
			if y1 is not None:
				if y1 and y1 in pair:
					if y2 not in pair:
						y2 = False
				elif y2 and y2 in pair:
					y1 = False
				else:
					x1 = False
					if x2 is False:
						break
			else:
				(y1, y2) = pair
	if x2 is not False:
		if x2 not in pair:
			if y3 is not None:
				if y3 and y3 in pair:
					if y4 not in pair:
						y4 = False
				elif y4 and y4 in pair:
					y3 = False
				else:
					x2 = False
					if x1 is False:
						break
			else:
				(y3, y4) = pair
if x1 or x2:
	print('yes')
else:
	print('no')


from collections import defaultdict
from itertools import combinations
from itertools import permutations

class RestAPI(object):

	def __init__(self, n, m, pairs):
		self.pairs = pairs[:]
		self.n = n
		self.m = m
		self.xy_cnt_dt = defaultdict(int)
		self.xy_dt = defaultdict(list)
		for (i, (a, b)) in enumerate(self.pairs):
			self.xy_cnt_dt[a] += 1
			self.xy_cnt_dt[b] += 1
			self.xy_dt[a] += [i]
			self.xy_dt[b] += [i]
		self.xy_cnt_dt = sorted(self.xy_cnt_dt.items(), key=lambda x: x[1])

	def function(self):
		for (i, (x, cnt_x)) in reversed(list(enumerate(self.xy_cnt_dt))):
			if cnt_x >= (self.m + 1) // 2:
				if cnt_x >= self.m - 1:
					return 'YES'
				scnd = set()
				for j in set(range(self.m)) - set(self.xy_dt[x]):
					(lf, rt) = self.pairs[j]
					if not scnd:
						scnd = set([lf, rt])
					else:
						scnd &= set([lf, rt])
						if not scnd:
							break
				if scnd:
					return 'YES'
			else:
				return 'NO'
		return 'NO'
(n, m) = map(int, input().split())
pairs = [tuple(map(int, input().split())) for _ in range(m)]
api = RestAPI(n, m, pairs)
response = api.function()
print(response)


(n, m) = list(map(int, input().split()))
arr = []
for q in range(m):
	arr.append(list(map(int, input().split())))
(a, b) = arr[0]
c = -1
d = -1
flag1 = 1
flag2 = 1
flag3 = 1
flag4 = 1
flag5 = 1
for w in range(m):
	if a not in arr[w] and b not in arr[w]:
		c = arr[w][0]
		d = arr[w][1]
		flag1 = 0
		break
if c != -1:
	for e in range(m):
		if a not in arr[e] and c not in arr[e]:
			flag2 = 0
		if a not in arr[e] and d not in arr[e]:
			flag3 = 0
		if b not in arr[e] and c not in arr[e]:
			flag4 = 0
		if b not in arr[e] and d not in arr[e]:
			flag5 = 0
if flag1 == 1 or (c != -1 and flag2 == 1) or (c != -1 and flag3 == 1) or (c != -1 and flag4 == 1) or (c != -1 and flag5 == 1):
	print('YES')
else:
	print('NO')


dic = {}
(n, m) = [int(i) for i in input().split()]
data = []
for i in range(m):
	(a, b) = [int(i) for i in input().split()]
	data.append((a, b))
	if a not in dic:
		dic[a] = set()
	dic[a].add(i)
	if b not in dic:
		dic[b] = set()
	dic[b].add(i)
lis = list(dic.keys())
lis.sort(key=lambda elem: len(dic[elem]))

def good(a, s):
	if s.issubset(dic[a]):
		return True
	return False
flag = False
for i in range(-1, -1 * min(m + 1, 5), -1):
	need = set(range(m)) - dic[lis[i]]
	if len(need) == 0:
		flag = True
		break
	f = need.pop()
	need.add(f)
	if good(data[f][0], need) or good(data[f][1], need):
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


import math
import heapq, bisect
import sys
from collections import deque
from fractions import Fraction
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
(n, m) = map(int, input().split())
a1 = []
for i in range(m):
	(a, b) = map(int, input().split())
	a1.append((a, b))

def check(i1, j):
	for i in range(m):
		if a1[i][0] == i1 or a1[i][1] == i1:
			continue
		elif a1[i][0] == j or a1[i][1] == j:
			continue
		else:
			return False
	return True
f = a1[0][0]
fl = 1
for i in range(m):
	if a1[i][0] != f and a1[i][1] != f:
		fl = 0
		if check(a1[i][0], f) or check(a1[i][1], f):
			fl = 1
			print('YES')
			sys.exit()
		else:
			break
f = a1[0][1]
fl = 1
for i in range(m):
	if a1[i][0] != f and a1[i][1] != f:
		fl = 0
		if check(a1[i][0], f) or check(a1[i][1], f):
			fl = 1
			print('YES')
			sys.exit()
		else:
			break
if fl == 0:
	print('NO')
else:
	print('YES')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = []
for i in range(m):
	(a, b) = map(int, input().split())
	l.append((a, b))
for i in range(2):
	indx = l[0][i]
	t = [0] * (n + 1)
	ans = 0
	for j in l:
		if j[0] != indx and j[1] != indx:
			t[j[0]] += 1
			t[j[1]] += 1
			ans += 1
	if max(t) == ans:
		print('YES')
		exit()
print('NO')


import sys
_ = input()
lines = [l for l in sys.stdin]
(x1, y1) = lines[0].split()
l2 = []
for line in lines:
	if not x1 in line.split() and (not y1 in line.split()):
		l2 = line
		break
if l2 == []:
	print('YES')
	exit()
(x2, y2) = l2.split()
candidates = [[x1, x2], [x1, y2], [y1, x2], [y1, y2]]
for line in lines:
	for c in candidates:
		if not c[0] in line.split() and (not c[1] in line.split()):
			candidates.remove(c)
	if candidates == []:
		print('NO')
		exit()
print('YES')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m) = mapin()
s = set([])
for i in range(m):
	p = listin()
	p.sort()
	p = tuple(p)
	s.add(p)
z = list(s)
n = len(s)
degree = defaultdict(int)
for i in z:
	degree[i[0]] += 1
	degree[i[1]] += 1
p = list(degree.keys())
q = list(degree.values())
deg = []
for i in range(len(q)):
	deg.append((q[i], p[i]))
deg.sort(reverse=True)
if deg[0][0] + deg[1][0] > n:
	print('YES')
elif deg[0][0] + deg[1][0] < n:
	print('NO')
else:
	k = defaultdict(list)
	for i in deg:
		k[i[0]].append(i[1])
	for i in k.keys():
		if n - i in k:
			for a in k[i]:
				for b in k[n - i]:
					if (min(a, b), max(a, b)) not in s and a != b:
						print('YES')
						exit()
	print('NO')