Problem:
 Score : 200 points    Problem Statement There are four towns, numbered 1,2,3 and 4 .
Also, there are three roads. The i -th road connects different towns a_i and b_i bidirectionally.
No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.      Constraints  1 \leq a_i,b_i \leq 4(1\leq i\leq 3)  a_i and b_i are different. (1\leq i\leq 3)  No two roads connect the same pair of towns.  Any town can be reached from any other town using the roads.         Input Input is given from Standard Input in the following format:  a_1  b_1  a_2  b_2  a_3  b_3       Output If we can visit all the towns by traversing each of the roads exactly once, print YES ; otherwise, print NO .        Sample Input 1 4 2
1 3
2 3      Sample Output 1 YES  We can visit all the towns in the order 1,3,2,4 .       Sample Input 2 3 2
2 4
1 2      Sample Output 2 NO       Sample Input 3 2 1
3 2
4 3      Sample Output 3 YES

Solution (Python):
C=[0]*4
for i in range(3):
  a,b=map(int,input().split())
  C[a-1]+=1
  C[b-1]+=1
print("YES" if C.count(1)==2 and C.count(2)==2 else "NO")

Solution (Python):
ans = [0, 0, 0, 0]
for i in range(3):
	x = list(map(int, input().split()))
	for xi in x:
		ans[xi - 1] += 1
if sorted(ans) == [1, 1, 2, 2]:
	print("YES")
else:
	print("NO")

Solution (Python):
from collections import Counter

E = []
for _ in range(3):
    a, b = map(int, input().split())
    E.append(a); E.append(b)
cnt = Counter(E)
print('YES' if max(cnt.values()) == 2 else 'NO')

Solution (Python):
from itertools import permutations

ways = [tuple(map(int, input().split())) for _ in range(3)]
for p in permutations(ways, 3):
    path1 = [p[0][0], p[0][1]]; path2 = [p[0][1], p[0][0]]
    for i in range(1, 3):
        if path1[-1] in p[i]:
            a, b = p[i]; path1.append(a if path1[-1] == b else b)
        if path2[-1] in p[i]:
            a, b = p[i]; path2.append(a if path2[-1] == b else b)
    if max(len(path1), len(path2)) == 4: print('YES'); break;
else: print('NO')

Solution (Python):
Inp1 = list(input().split())
Inp1.extend(input().replace(' ',''))
Inp1.extend(input().replace(' ',''))

Inp_dict = {'1':0,'2':0,'3':0,'4':0}
for i in Inp1:
	Inp_dict[i] +=1

ans = list()
for k in Inp_dict.keys():
	if Inp_dict[k] == 2 : ans.extend(k)

if len(ans) == 2: print('YES')
else: print('NO')

Solution (Python):
import collections

l=[]
for i in range(3):
  A1,A2=map(int,input().split())
  l.append(A1)
  l.append(A2)

c=collections.Counter(l).most_common()

if len(set(l))==4 and c[0][1]==2:
  print('YES')
else:
  print('NO')

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

li_w = [a1, b1, a2, b2, a3, b3]

result = [li_w.count(i) for i in range(1, 5)]
if result.count(2) == 2 and result.count(1) == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
x = [0, 0, 0, 0]
for i in range(3):
    a, b = [int(_) for _ in input().split()]
    x[a-1] += 1
    x[b-1] += 1

if max(x) <= 2:
    print("YES")
else:
    print("NO")

Solution (Python):
deg = [0] * 5
for _ in range(3):
  a,b = map(int,input().split())
  deg[a] += 1
  deg[b] += 1

bl = max(deg) <= 2
answer = 'YES' if bl else 'NO'
print(answer)

Solution (Python):
ab=[list(map(int,input().split())) for i in range(3)]
cnt=[0,0,0,0]
ans='YES'
for i in ab:
    for j in i:
        cnt[j-1]+=1
for i in cnt:
    if i>=3:
        ans='NO'
print(ans)

Solution (Python):
ab=[]
for _ in range(3):
    a,b = map(int,input().split())
    ab.append(a)
    ab.append(b)
for i in range(1,5):
    if ab.count(i)>=3:
        print("NO")
        exit()
print("YES")

Solution (Python):
d=[0]*4
for i in range(3):
    a,b=map(int,input().split())
    d[a-1]+=1
    d[b-1]+=1
d.sort()
print(["NO","YES"][d[0]==d[1]==1 and d[2]==d[3]==2])

Solution (Python):
from collections import Counter
cnt = Counter()
for i in range(3):
  cnt.update([int(item) for item in input().split()])
a = list(cnt.values())
a.sort()
if a[0] == 1 and a[1] == 1 and a[2] == 2 and a[3] == 2:
  print("YES")
else:
  print("NO")

Solution (Python):
lis = []
for i in range(3):
  lis = lis + list(map(int, input().split()))


ans = "YES"

for i in range(4):
  a = lis.count(i+1)
  if a >= 3:
    ans = "NO"
    break
print(ans)

Solution (Python):
city={1:0,2:0,3:0,4:0}
for q in range(3):
    n,k=map(int,input().split())
    city[n]+=1
    city[k]+=1


if min(city.values()) ==0 or max(city.values())==3:
    print("NO")
else:
    print("YES")

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())


a = list(mi()) + list(mi()) + list(mi())
cnts = [a.count(i) for i in range(1,5)]

if max(cnts) == 3: print('NO')
else: print('YES')

Solution (Python):
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l3 = list(map(int,input().split()))

l = l1 + l2 + l3

cnt = []
for i in range(1,5):
    c = 0
    for j in l:
        if i == j:
            c += 1
    cnt.append(c)

cnt.sort()

if cnt == [1,1,2,2] :
    print("YES")
else:
    print("NO")

Solution (Python):
c = [0]*4
for i in range(3):
        a,b = map(int,input().split())
        a,b = a-1,b-1
        c[a] += 1
        c[b] += 1
d = c.count(2)
print('YES') if d == 2 else print('NO')

Solution (Python):
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) == [0,1,1,2,2]:
  print("YES")
else:
  print("NO")

Solution (Python):

"""
B - Path
https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_b

"""
import sys


def solve(path):
    res = [0] * 5
    for a, b in path:
        res[a] += 1
        res[b] += 1
    res.sort()
    if res == [0, 1, 1, 2, 2]:
        return 'YES'
    return 'NO'


def main(args):
    path = [[int(i) for i in input().split()] for _ in range(3)]
    ans = solve(path)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
l=[0]*4
for i in range(3):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
l.sort()
if l==[1,1,2,2]:print("YES")
else:print("NO")

Solution (Python):
li = []
for i in range(3):	
  a,b = map(int,input().split())
  li.append(a)
  li.append(b)
li.sort()
if li==[1, 2, 2, 3, 3, 4]:
  print("YES")
else:
  print("NO")

Solution (Python):
a = [0] * 4
for i in range(3) :
  x, y = map(int, input().split())
  a[x-1] = a[x-1] + 1
  a[y-1] = a[y-1] + 1
if a[0] ^ a[1] ^ a[2] ^ a[3] == 0 : print("YES")
else : print("NO")

Solution (Python):
l=[]
for i in range(3):
    l.extend(list(map(int,input().split())))
m=[0,0,0,0]
for i in range(1,5):
    m[i-1]=l.count(i)
if sorted(m) == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
aaa = []
for i in range(3):
    a, b = map(int, input().split())
    aaa.append(a)
    aaa.append(b)

aaa.sort()
cnt = 0
prev = aaa[0]
c = []
for i, aa in enumerate(aaa):
    if aa == prev:
        cnt += 1
    else:
        c.append(cnt)
        prev = aa
        cnt = 1
c.append(cnt)
c.sort()
if [1, 1, 2, 2] == c:
    print("YES")
else:
    print("NO")

Solution (Python):
dim = [0,0,0,0]

for _ in range(3):
	a, b = [int(x) for x in input().split()]
	dim[a-1] += 1
	dim[b-1] += 1

if 3 in dim:
	print("NO")
else:
	print("YES")

Solution (Python):
a1,b1=input().split()
a2,b2=input().split()
a3,b3=input().split()
t=a1+b1+a2+b2+a3+b3
if t.count("1")*t.count("2")*t.count("3")*t.count("4")==0 or max(t.count("1"),t.count("2"),t.count("3"),t.count("4"))==3:
    print("NO")
else:
    print("YES")

Solution (Python):
abs = [[int(x) for x in input().split()] for _ in range(3)]

ns = {1: 0, 2: 0, 3: 0, 4: 0}
for a, b in abs:
    ns[a] += 1
    ns[b] += 1
ans = max(ns.values()) == 2

print("YES" if ans else "NO")

Solution (Python):
arr=[]
for i in range(3):
  a,b=map(int,input().split())
  arr.append(a)
  arr.append(b)
if arr.count(1)==3 or arr.count(2)==3 or arr.count(3)==3 or arr.count(4)==3:
  print('NO')
else:
  print('YES')

Solution (Python):
if __name__=="__main__":
    ind = [0, 0, 0, 0]
    for i in range(3):
        x, y = input().split(' ')
        x = int(x);
        y = int(y);
        ind[x - 1] += 1
        ind[y - 1] += 1
    sum = 0;
    for i in ind:
        sum += (i & 1)
    if sum == 0 or sum == 2:
        print('YES')
    else:
        print('NO')

Solution (Python):
a,b = input().split()
c,d = input().split()
e,f = input().split()
A = [a,b,c,d,e,f]
if max(A.count('1'),A.count('2'),A.count('3'),A.count('4')) >= 3:
	print("NO")
else:
	print("YES")

Solution (Python):

import sys

YES = "YES"  
NO = "NO"  

def solve(a: "List[int]", b: "List[int]"):
    count = [0] * 4
    for i in range(3):
        count[a[i] - 1] += 1
        count[b[i] - 1] += 1
    if max(count) >= 3:
        ret = NO
    else:
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = [int()] * (3)  
    b = [int()] * (3)  
    for i in range(3):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(a, b)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

adj=[[] for i in range(4)]
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

for i in range(3):
    a,b=MAP()
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
for i in range(4):
    if len(adj[i])>2:
        print("NO")
        exit()
print("YES")

Solution (Python):
a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
e, f = map(int, raw_input().split())
r = a^b^c^d^e^f
bad = 1^2^3^4
if r == bad:
  print "NO"
else:
  print "YES"

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
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 ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=4,3
nodes=[[] for i in range(N)]
for i in range(M):
    a,b=MAP()
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)

if all(len(nodes[i])<=2 for i in range(N)):
    YES()
else:
    NO()

Solution (Python):
array = []
for i in range(3):
    array.append([int(i) for i in input().split()])
array_and = set(array[0]) & set(array[1]) & set(array[2])
if len(array_and) == 0:
    print('YES')
else:
    print('NO')

Solution (Python):
AB = [list(map(int, input().split())) for _ in range(3)]

for i in range(1, 5):
    cnt = 0
    for ab in AB:
        if i in ab:
            cnt += 1
        if cnt == 3:
            print("NO")
            exit()
else:
    print("YES")

Solution (Python):

a = [0] * 3
b = [0] * 3

for i in range(3):
    a[i],b[i] = map(int,input().split())
    
count = [0] * 4
for i in range(3):
    for j in range(1,5):
        if(a[i] == j):
            count[j-1] += 1
        if(b[i] == j):
            count[j-1] += 1
        
if max(count) > 2:
    print('NO')
else:
    print('YES')

Solution (Python):
A=[]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]
A+=[int(i) for i in input().split()]

B = [A.count(i) for i in range(1,5)]
if B.count(2) == 2 and B.count(1) == 2:
  print("YES")
else:
  print("NO")

Solution (Python):
import collections

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

x = a+b+c
c = collections.Counter(x)

if len(list(filter(lambda x:x>2,c.values()))) > 0:
    print("NO")
else:
    print("YES")

Solution (Python):
import collections

li = []
for i in range(3):
    li += list( map( int, input().split() ) )

c = collections.Counter( li )
if c.most_common()[0][1] >= 3: print( 'NO' )
else: print( 'YES' )

Solution (Python):


from collections import Counter
a = Counter()
for _ in range(3):
    m,n = map(int, input().split())
    a[m]  += 1
    a[n] += 1
    if a[m] > 2 or a[n] > 2:
        print("NO")
        exit(0)
print("YES")

Solution (Python):
a = [[int(_) for _ in input().split()] for _ in range(3)]
a = sum(a, [])
num = []
for i in range(1, 5):
    num.append(a.count(i))

print("YES" if num.count(2)==2 and num.count(1)==2 else "NO")

Solution (Python):
lis =[]
for _ in range(3):
  a, b = map(int, input().split())
  lis.append(a)
  lis.append(b)
boo = False
for i in range(1, 5):
  if lis.count(i) >= 3:
    boo = True
if boo:
  print("NO")
else:
  print("YES")

Solution (Python):
flag = 0
a = []
for x in range(3):
    a +=list(map(int,input().split()))
if a.count(1) == 2:
    flag += 1
if a.count(2) == 2: 
    flag += 1
if a.count(3) == 2:
    flag += 1
if a.count(4) == 2:
    flag += 1
if flag == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
x=[0,0,0,0]
for i in range(3):
  a,b=map(int,input().split())
  x[a-1]+=1
  x[b-1]+=1
if x.count(3)==0:print("YES")
else:print("NO")

Solution (Python):
l = [0, 0, 0, 0, 0]
for _ in range(3):
  a, b = map(int,input().split())
  l[a] += 1
  l[b] += 1
if sorted(l) == [0, 1, 1, 2, 2]:
  print("YES")
else:
  print("NO")

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007



"""
s = S()
n = len(s)
if s == list("keyence"):
    print("YES")
    quit()
for i in range(n):
    for j in range(i+1,n):
        print(s[:i]+s[j:])
        if s[:i]+s[j:] == list("keyence"):
            print("YES")
            quit()
print("NO")
"""

c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")

Solution (Python):
c = [0]*5
for i in range(3):
    a, b = map(int, input().split())
    c[a] += 1
    c[b] += 1
if max(c) == 3:
    print('NO')
else:
    print('YES')

Solution (Python):
p = [0,0,0,0]
for i in range(3):
    ai, bi = map(int, input().split())
    p[ai-1] += 1
    p[bi-1] += 1

if 3 in p:
    print('NO')
else:
    print('YES')

Solution (Python):
oira = str()
S = str()
for i in range(3):
	s = input().split()
	S += s[0] + s[1]
if (S.count('1') == 3)|(S.count('2')==3)|(S.count('3')==3)|(S.count('4')==3):
	print('NO')
else:
	print('YES')

Solution (Python):
ans = [0,0,0,0]
for i in range(3):
  for j in input().split():
    ans[int(j)-1]+=1
if ans.count(1)==ans.count(2)==2:
  print('YES')
else:
  print('NO')

Solution (Python):
list_ = [[int(x) for x in input().split()] for i in range(3)]
count = [0]*4
for i in range(3):
  count[list_[i][0]-1]+=1
  count[list_[i][1]-1]+=1
if 3 in count:
  print('NO')
else:
  print('YES')

Solution (Python):
L = [set(map(int,input().split())) for i in range(3)]
L += [set([1,0]),set([2,0]),set([3,0]),set([4,0])]
import copy
def dfs(left_towns, current_town):
    if len(left_towns) == 0:
        return 1
    
    ret = 0
    for t in left_towns:
        if set([t,current_town]) in L:
            new_left_towns = copy.deepcopy(left_towns)
            new_left_towns.remove(t)
            ret += dfs(new_left_towns, t)
    
    if ret>0:
        return 1
    else:
        return 0

ans = 'YES' if dfs([1,2,3,4],0)>0 else 'NO'
print(ans)

Solution (Python):
AB = [[int(i) for i in input().split()] for j in range(3)]

List = [0 for i in range(4)]
for i in range(len(AB)):
    for j in range(2):
        List[AB[i][j]-1] += 1
one = 0
two = 0
for i in List:
    if i == 1:
        one += 1
    if i == 2:
        two += 1
ans = "NO"
if one == 2 and two == 2:
    ans = "YES"

print(ans)

Solution (Python):
edges = [map(int, input().split()) for _ in range(3)]

flattened = [i for sub in edges for i in sub]
cont = sorted([flattened.count(i) for i in range(1, 5)])
ans = 'YES' if cont == [1,1,2,2] else 'NO'
print(ans)

Solution (Python):
E = []
for i in range(3):
  E.append(list(map(int, input().split())))
  
A = [0]*4

for i in range(3):
  A[E[i][0] - 1] += 1
  A[E[i][1] - 1] += 1
  
if A[0] * A[1] * A[2] * A[3] == 4:
  print('YES')
else:
  print('NO')

Solution (Python):
ab=[list(map(int,input().split())) for _ in range(3)]
a,b,c,d=0,0,0,0
for k in ab:
    for t in k:
        if t==1:
            a+=1
        elif t==2:
            b+=1
        elif t==3:
            c+=1
        else:
            d+=1
z=[a,b,c,d]
if z.count(2)==2 and z.count(1)==2:
    print("YES")
else:
    print("NO")

Solution (Python):
L = [0, 0, 0, 0]
for i in range(3):
	a, b = list(map(int, input().split()))
	L[a - 1] += 1
	L[b - 1] += 1

L = sorted(L)
if L[0] == 1 and L[-1] == 2:
	print("YES")
else:
	print("NO")

Solution (Python):
l1 = set(tuple(map(int,input().split())))
l2 = set(tuple(map(int,input().split())))
l3 = set(tuple(map(int,input().split())))

L = (l1,l2,l3)

town = [1,2,3,4]

ret = 0

for t1 in town:
    for t2 in town:
        if t1==t2: continue
        if not {t1,t2} in L: continue
        for t3 in town:
            if t3==t2 or t3==t1: continue
            if not {t2,t3} in L: continue
            for t4 in town:
                if t4==t3 or t4==t2 or t4==t1: continue
                if not {t3,t4} in L: continue
                ret += 1

ans = 'YES' if ret>0 else 'NO'
print(ans)

Solution (Python):
L = []
l1 = set(tuple(map(int,input().split())))
l2 = set(tuple(map(int,input().split())))
l3 = set(tuple(map(int,input().split())))
L.append(l1)
L.append(l2)
L.append(l3)
L += [{0,1},{0,2},{0,3},{0,4}]

def dfs(left_town, current_town):
    if left_town == []:
        return 1

    ret = 0
    for t in left_town:
        if {current_town, t} in L:
            ret += dfs([left_town[index] for index,val in enumerate(left_town) if not val==t],t)
    
    if ret == 0:
        return 0
    else:
        return 1

ans = "YES" if dfs([1,2,3,4],0)==1 else "NO"
print(ans)

Solution (Python):
import sys



towncount = [0, 0, 0, 0]
for i in range(3):
	line = sys.stdin.readline()
	values = line.split(" ")
	for value in values:
		towncount[int(value)-1] += 1

for count in towncount:
	if count > 2:
		print("NO")
		exit()

print("YES")

Solution (Python):
load = list()
for i in range(3):
  a, b = list(map(int, input().split()))
  load.append(a)
  load.append(b)
error = 0
for i in range(1, 5):
  if load.count(i) >= 3:
    error += 1
if error >= 1:
  print("NO")
else:
  print("YES")

Solution (Python):
t = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    t[a - 1] += 1
    t[b - 1] += 1
print('NO') if max(t)==3 else print('YES')

Solution (Python):
count1=0
count2=0
count3=0
count4=0
for i in range(3):
  a,b=(int(x) for x in input().split())
  if a==1:
    count1 = count1 + 1
  elif a==2:
    count2 = count2 + 1
  elif a==3:
    count3 = count3 + 1
  elif a==4:
    count4 = count4 + 1
  if b==1:
    count1 = count1 + 1
  elif b==2:
    count2 = count2 + 1
  elif b==3:
    count3 = count3 + 1
  elif b==4:
    count4 = count4 + 1
if count1>2 or count2>2 or count3>2 or count4>2:
  print("NO")
else:
  print("YES")

Solution (Python):
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
l=[a1,a2,a3,b1,b2,b3]
L=[]
for i in range(1,5):
  L.append(l.count(i))
L.sort()
if L==[1,1,2,2]:print('YES')
else:print('NO')

Solution (Python):
arr = []
for i in range(3):
  a, b = map(int, input().split())
  arr.append(a)
  arr.append(b)

import collections
c = collections.Counter(arr)
if (len(set(arr))!=4) or (3 in c.values()):
  print("NO")
else:
  print("YES")

Solution (Python):
def solution(edges):
    num_of_neighbor = {}
    for e in edges:
        if e[0] in num_of_neighbor:
            num_of_neighbor[e[0]] += 1
        else:
            num_of_neighbor[e[0]] = 1
        if e[1] in num_of_neighbor:
            num_of_neighbor[e[1]] += 1
        else:
            num_of_neighbor[e[1]] = 1
    n_2 = 0
    n_1 = 0
    for n in num_of_neighbor:
        if num_of_neighbor[n] == 2:
            n_2 += 1
        elif num_of_neighbor[n] == 1:
            n_1 += 1

    if n_2 == 2 and n_1 == 2:
        return 'YES'
    else:
        return 'NO'

e1 = [int(s) for s in input().split(' ')]
e2 = [int(s) for s in input().split(' ')]
e3 = [int(s) for s in input().split(' ')]
edges = [e1, e2, e3]
print(solution(edges))

Solution (Python):
def solution(path1, path2, path3):
    counts = [0, 0, 0, 0]
    paths = [path1, path2, path3]
    for path in paths:
        counts[path[0] - 1] += 1
        counts[path[1] - 1] += 1

    countsOfCounts = [0, 0]
    for count in counts:
        if count == 1:
            if countsOfCounts[0] == 2:
                return "NO"
            countsOfCounts[0] += 1
        elif count == 2:
            if countsOfCounts[1] == 2:
                return "NO"
            countsOfCounts[1] += 1
        else:
            return "NO"
    return "YES"


path1 = [int(s) for s in input().split(' ')]
path2 = [int(s) for s in input().split(' ')]
path3 = [int(s) for s in input().split(' ')]

print(solution(path1, path2, path3))

Solution (Python):
D = [0]*4
for i in range(3):
    a, b = map(int, input().split())
    D[a-1] += 1
    D[b-1] += 1
C = [0]*4
for d in D:
    C[d] += 1
print("YES" if C == [0, 2, 2, 0] else "NO")

Solution (Python):
noc = [0] * 4

for i in range(3):
    l = list(map(int, input().split()))
    for j in range(2):
        noc[l[j] - 1] += 1

if 3 in noc:
    print('NO')
else:
    print('YES')

Solution (Python):
g=[0,0,0,0]
one=0
two=0

for i in range(3):
  a,b=map(int,input().split())
  g[a-1]+=1
  g[b-1]+=1
  
for i in range(len(g)):
  if g[i]==1:
    one+=1
  if g[i]==2:
    two+=1
if one==2 and two==2:
  print('YES')
else:
  print('NO')

Solution (Python):
n = [list(map(int, input().split())) for _ in range(3)]
c = [0] * 4
for i in n:
    for j in i:
        c[j - 1] += 1
a = len(list(filter(lambda x : x % 2 == 1, c)))
if a == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
r = [input().split(" ") for i in range(3)]
r_f = [f for i in r for f in i]
judge = "NO" if max([r_f.count(str(i)) for i in range(1,5)])==3 else "YES"
print(judge)

Solution (Python):
cnt = [0] * 4
for i in range(3):
    a, b = list(map(int, input().split()))
    cnt[a-1] += 1
    cnt[b-1] += 1
cnt = sorted(cnt)
print("YES" if cnt == [1, 1, 2, 2] else "NO")

Solution (Python):
path=[]
for i in range(3):
    n, k = map(int, input().split())
    path.append(n)
    path.append(k)

if 0 < path.count(1) < 3 and 0 < path.count(2) < 3 and 0 < path.count(3) < 3 and 0 < path.count(4) < 3:
    print('YES')
else:
    print('NO')

Solution (Python):
path = {}
for i in range(1,5):
    city = int(i)
    path[i] = 0


for i in range(3):
    city_1 ,city_2 = map(int,input().split())
    path[city_1] += 1
    path[city_2] += 1

d = 1
for value in path.values():
    d *= value

if d == 4:
    print("YES")
else:
    print("NO")

Solution (Python):
import numpy as np
ans = 'YES'
a = np.array([])
for i in range(3):
    b, c = input().split()
    a = np.append(a, [b, c])
a = a.astype(np.int32)
for i in range(4):
    count = np.sum(a == i + 1)
    if count > 2:
        ans = 'NO'
        break
print(ans)

Solution (Python):
import itertools
data = []
for i in range(3):
    a,b = map(int,input().split())
    data.append([a,b])
    data.append([b,a])

seq = [1,2,3,4]
test = list(itertools.permutations(seq))
check = False
for i in range(len(test)):
    temp = True
    for k in range(3):
        if [test[i][k],test[i][k+1]] not in data:
            temp = False
            break
    if temp:
        check = True
        break
if check:
    print("YES")
else:
    print("NO")

Solution (Python):
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    for i in range(4):
        if sum(x==i+1 for x in a) > 2:
            print('NO')
            return
    print('YES')
f()

Solution (Python):
pathes = []
for i in range(3):
  pathes += map(int,input().split(' '))

r = 1
for i in range(1,5):
  r *= pathes.count(i)

result = 'YES' if r%3>0 else 'NO'

print(result)

Solution (Python):
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    b = []
    for i in range(4):
        b.append(sum(x==i+1 for x in a))
    for i in b:
        if i > 2:
            print('NO')
            return
    print('YES')
f()

Solution (Python):

import sys





"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def d(self, p):
        re = 0
        for i in range(len(p) - 1):
            re += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        return re


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = [0] * 4
    for _ in [0] * 3:
        a = ip.IL()
        s[a[0] - 1] += 1
        s[a[1] - 1] += 1

    o = sum(x for x in s if x % 2 == 1)
    if o == 0 or o == 2:
        print("YES")
    else:
        print("NO")


main()