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):
a1,b1=input().split()
a2,b2=input().split()
a3,b3=input().split()
lista=[a1,a2,a3,b1,b2,b3]
yn=0
for i in range(1,5):
    if lista.count(str(i))==0 or lista.count(str(i))>2:
        yn=1
        break
if yn==1:
    print("NO")
else:
    print("YES")

Solution (Python):
import heapq
from sys import stdin
input = stdin.readline














     
def main():
    count =[0]*4
    for i in range(3):
       a,b = map(int, input().split())
       count[a-1]+=1
       count[b-1]+=1
    flag = True
    for i in count:
        if i ==3:
            flag=False
    if flag:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=4
es=[[] for i in range(n)]
for i in range(n-1):
   a,b=map(int,input().split())
   es[a-1].append(b-1)
   es[b-1].append(a-1)
use=sorted([len(es[i]) for i in range(4)])

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

Solution (Python):


paths = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    paths[a].append(b)
    paths[b].append(a)

start = 0
for i in range(4):
    if len(paths[i]) == 1:
        start = i
        break

visited = {start}
def dfs(n):
    if len(paths[n]) >= 3:
        print('NO')
        exit()
    for p in paths[n]:
        if p in visited:
            continue
        visited.add(p)
        dfs(p)

dfs(start)

if len(visited) == 4:
    print('YES')
else:
    print('NO')

Solution (Python):
node = set([1,2,3,4])
for _ in range(3):
  a,b = map(int,input().split())
  node = node.intersection(set([a,b]))
  
print('NO' if len(node) else 'YES')

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

resolve()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    tree = [[] for _ in range(4)]
    for _ in range(3):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    def dfs(v, p):
        for u in tree[v]:
            if u == p:
                continue
            elif visited[u]:
                return
            else:
                visited[u] = True
                dfs(u, v)
                return

    visited = [False] * 4
    visited[0] = True
    dfs(0, -1)
    print("YES" if visited.count(True) == 4 else "NO")


if __name__ == '__main__':
    resolve()

Solution (Python):
abl = [map(int,input().split()) for nesya in range(3)]
s = [1,1,2,2,3,3,4,4]
c = 0
for ab in abl:
  for n in ab:
    if n in s:
      s.remove(n)
    else:
      c += 1
if c == 0:
  print('YES')
else:
  print('NO')

Solution (Python):
from collections import defaultdict,deque

N = 4
d = defaultdict(list)
for i in range(3):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)


for i in range(1,5):
    dist = [None]*N
    q = deque()
    s = i  
    q.append(s)
    dist[s-1] = 0

    while len(q)!=0:
        From = q.popleft()
        for To in d[From]:
            if dist[To-1] == None:
                q.append(To)
                dist[To-1] = dist[From-1]+1
    if set(dist)=={0,1,2,3}:
        print("YES")
        exit()
print("NO")

Solution (Python):
import collections
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())
arr = [a,b,c,d,e,f]
A = collections.Counter(arr).most_common()

if len(A) == 4:
    if A[0][1] == 2 and A[1][1] == 2 and A[2][1] == 1 and A[3][1] == 1:
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Solution (Python):
from collections import defaultdict
cnt = defaultdict(int)
for i in range(3):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

print("YES" if max(cnt.values()) == 2 and min(cnt.values()) == 1 else "NO")

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

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

Solution (Python):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    vec = [0]*4
    for x in range(3):
        A,B = map(int, input().split())
        A -= 1
        B -=1
        vec[A] += 1
        vec[B] += 1
    
    if(vec[0] == 1 and vec[1] == 2 and vec[2] == 2 and vec[3] == 1):
        print("YES")
    else:
        print("NO")



if __name__ == '__main__':
    solve()

Solution (Python):
n = 3
num_list = [list(map(int, input().split())) for _ in range(n)]
N = (sum(num_list, []))
N1 = N.count(1)
N2 = N.count(2)
N3 = N.count(3)
N4= N.count(4)
if N1 > 2 or N2 > 2 or N3 > 2 or N3 > 2 or N4 > 2:
    print('NO')
else:
    print('YES')

Solution (Python):

L=[0 for i in range(4)]

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

cnt1=0
cnt2=0

for i in range(4):
    if L[i]==1:
        cnt1+=1
    elif L[i]==2:
        cnt2+=1

if cnt1==cnt2==2:
    print("YES")
else:
    print("NO")

Solution (Python):
A = list(map(int,(input().split())))
S1 = set(A)
S2 = set(A)
for i in range(2):
    B = list(map(int,input().split()))
    S1 = S1 | set(B)
    S2 = S2 & set(B)
if len(S1) == 4 and len(S2) == 0:
    print("YES")
else:
    print("NO")

Solution (Python):
import collections
a1,b1 = list(map(int,input().split()))
a2,b2 = list(map(int,input().split()))
a3,b3 = list(map(int,input().split()))
dd = collections.defaultdict(int)
dd[a1] += 1
dd[a2] += 1
dd[a3] += 1
dd[b1] += 1
dd[b2] += 1
dd[b3] += 1
for i in dd.values():
    if i > 2:
        print('NO')
        exit()
print('YES')

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

mx = 0
for i in range(1, 5):
    mx = max(mx, li.count(i))

if mx == 3:
    ans = "NO"
else:
    ans = "YES"

print(ans)

Solution (Python):
listA=[]
import collections 
for i in range(3):
    B = list(map(int,input().split()))
    listA.append(B[0])
    listA.append(B[1])
listA=collections.Counter(listA)
listA = listA.most_common()
if listA[0][1] == 2 and listA[1][1] == 2 and listA[2][1] == 1 and listA[3][1] == 1:
    print("YES")
else:
    print("NO")

Solution (Python):
L = []
for _ in range(3):
  A,B = map(int,input().split()) 
  L.append(A)
  L.append(B)
L.sort()
M = []
a = L.count(1)
b = L.count(2)
c = L.count(3)
d = L.count(4)
M.append(a)
M.append(b)
M.append(c)
M.append(d)
M.sort()
if M == [1,1,2,2]:
  print('YES')
else:
  print('NO')

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

abcdef = [a,b,c,d,e,f]

from collections import Counter

cc = Counter(abcdef)

ccm = cc.most_common()

if ccm[0][1]==2 and ccm[1][1]==2 and ccm[2][1]==1 and ccm[3][1]==1:
    print('YES')
else:
    print('NO')

Solution (Python):
a=[0]*3
b=[0]*3

a[0],b[0]=map(int,input().split())
a[1],b[1]=map(int,input().split())
a[2],b[2]=map(int,input().split())

d=dict()
c=a+b
for i in c:
  if i not in d:
    d[i]=1
  else:
    d[i]+=1

mini=100
maxi=0
for j in d:
  mini=min(mini,d[j])
  maxi=max(maxi,d[j])


if mini==1 and maxi==2:
  print("YES")
else:
  print("NO")

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

Solution (Python):

connected_town_dict = {i:set() for i in range(1,5)}

for i in range(3):
    a,b = map(int, input().split())
    connected_town_dict[a].add(b)
    connected_town_dict[b].add(a)

for i in range(1,5):
    if len(connected_town_dict[i])!=1 and len(connected_town_dict[i])!=2:
         print("NO")
         break
else:
    print("YES")

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

a1, b1 = map(int, readline().split())
a2, b2 = map(int, readline().split())
a3, b3 = map(int, readline().split())
counter = sorted(list(Counter([a1, a2, a3, b1, b2, b3]).values()))
if counter == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Solution (Python):
count_list = [0,0,0,0]
for i in range(3):
  dis = [int(i) for i in input().split()]
  for j in dis:
    count_list[j-1] += 1

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

Solution (Python):
arr = list(map(int, input().split()))
flg = 0
for i in range(2):
  a,b = map(int, input().split())
  if arr[0] == a:
    arr.insert(0,b)
  elif arr[0] == b:
    arr.insert(0,a)
  elif arr[-1] == a:
    arr.append(b)
  elif arr[-1] == b:
    arr.append(a)
  elif i == 0:
    flg = 1
if len(arr) == 4 or flg == 1:
  print('YES')
else:
  print('NO')

Solution (Python):
from collections import*
print("YNEOS"[Counter(open(0).read().split()).most_common()[0][1]==3::2])

Solution (Python):
import sys
input = sys.stdin.readline


route = []

for i in range(3):
	a, b = map(int, input().split())	
	route.append(a)
	route.append(b)

count = 0

for i in range(1, 5):
	if route.count(i) >= 2:
		count += 1

if count >= 2:
	print('YES')
else:
	print('NO')

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





route =[0]*4
for i in range(3):
    a,b=mii()
    route[a-1]+=1
    route[b-1]+=1

cou = Counter(route)

ans1=0
ans2=0
for i in route:
    if i==1:
        ans1+=1
    elif i==2:
        ans2+=1

if ans1==2 and ans2==2:
    print("YES")
else:
    print("NO")

Solution (Python):

from collections import Counter, deque 












import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    L=[]
    for _ in range(3):
        a,b=map(int,input().split())
        L.append(a-1)
        L.append(b-1)
    LL=Counter(L).most_common()
    if LL[0][1]!=2:
        print('NO')
    else:
        print('YES')
    
    



resolve()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    a,b = map(int, input().split())
    c,d = map(int, input().split())
    e,f = map(int, input().split())
    c = Counter([a,b,c,d,e,f])
    a = 0
    b = 0
    for i in c.values():
        if i==1:
            a+=1
        if i==2:
            b+=1
    if a==2 and b==2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Solution (Python):

if False:
    N=int(input())
    if N%2==0: print(N//2-1)
    else: print(N//2)


if False:
    M,D=map(int,input().split())
    ans=0
    for m in range(1,M+1):
        for d in range(1,D+1):
            if len(str(d))==2:
                x,y=int(str(d)[0]),int(str(d)[1])
                if x>=2 and y>=2 and x*y==m:
                    ans+=1
    print(ans)


if False:
    N,K=map(int,input().split())
    MAX=N-K+1
    print(MAX-1 if K!=1 else 0)


if False:
    N,A,B=map(int,input().split())
    MAX=min(A,B)
    MIN=A+B-N if A+B>=N else 0
    print(MAX,MIN)


if True:
    cnt=[0 for _ in range(4)]
    for _ in range(3):
        a,b=map(int,input().split())
        cnt[a-1]+=1
        cnt[b-1]+=1
    cnt.sort()
    print('YES' if cnt==[1,1,2,2] else 'NO')

Solution (Python):
d = {i: 0 for i in range(1, 5)}
for i in range(3):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1

ans = 'YES'
for i in d.values():
    if i == 3:
        ans = 'NO'
        break

print(ans)

Solution (Python):

import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)

def main():
    s=defaultdict(int)
    for a in range(3):
        b,c=map(int,input().split())
        s[b]+=1
        s[c]+=1
    YN(not max(s.values())==3)

main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    N=[]
    for _ in range(3):
        a,b=map(int,input().split())
        N.append(a)
        N.append(b)
    N=Counter(N)
    NN=N.most_common(1)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    N=[]
    for _ in range(3):
        a,b=map(int,input().split())
        N.append(a)
        N.append(b)
    N=Counter(N)
    NN=N.most_common(1)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Solution (Python):

ans = [0] * 4

for i in range(3):
  a, b = map(int, input().split())
  ans[a-1] += 1
  ans[b-1] += 1
  
for i in ans:
  if i >= 3:
    print("NO")
    exit()

print("YES")

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

for i in range(3):
    a,b=map(int,input().split())
    li[a-1]+=1
    li[b-1]+=1

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

Solution (Python):
ab = [list(map(int, input().split())) for i in range(3)]
one, two, three, four = 0, 0, 0, 0
for i in ab:
    one += i.count(1)
    two += i.count(2)
    three += i.count(3)
    four += i.count(4)
if one == 3 or two == 3 or three == 3 or four == 3:
    print("NO")
else:
    print("YES")

Solution (Python):
from itertools import permutations

pas = [[0]*4 for i in range(4)]
for i in range(3):
        a, b = map(int, input().split())
        pas[a-1][b-1] = pas[b-1][a-1] = 1

ans = "NO"
for x in permutations(range(4)):
        cant = False
        for i in range(3):
                if pas[x[i]][x[i+1]]==0: cant = True
        if cant==False: ans = "YES"
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

dim = [0]*4

for _ in range(3):
	a, b = MAP()
	dim[a-1] += 1
	dim[b-1] += 1

c = Counter(dim)
if c[1] == 2 and c[2] == 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())

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

ans = "YES"
for i in range(1,5,1):
  if ls.count(i) == 3:
    ans ="NO"
print(ans)

Solution (Python):
x = list(map(int,(input().split())))
y = list(map(int,(input().split())))
z = list(map(int,(input().split())))
count1 =  0
count2 =  0
count3 =  0
count4 =  0

num = x + y + z

for i in range(len(num)):
    
    if num[i] == 1:
        count1 += 1
        if count1 >=3:
            print("NO")
            exit()
    if num[i] == 2:
        count2 += 1
        if count2 >=3:
            print("NO")
            exit()
    if num[i] == 3:
        count3 += 1
        if count3 >=3:
            print("NO")
            exit()
    if num[i] == 4:
        count4 += 1
        if count4 >=3:
            print("NO")
            exit()

print("YES")

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

ab = [list(map(int, input().split())) for _ in range(3)]
for i in range(len(ab)):
    a = ab[i][0]
    b = ab[i][1]
    d[a] += 1
    d[b] += 1
x = []
for v in d.values():
    x.append(v)
if x.count(1) == 2 and x.count(2) == 2:
    print('YES')
else:
    print('NO')

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

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

Solution (Python):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
li=[a,b,c,d,e,f]
x=[li.count(i) for i in range(1,5)]
if max(x)<3:
  print("YES")
else:
  print("NO")

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

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

if max(city)==2 and min(city)==1:
    print('YES')
else:
    print('NO')

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
l = []
for i in range(3):
    a,b = iim()
    l.append(a)
    l.append(b)

for i in range(1,5):
    if l.count(i) == 3:
        print('NO')
        exit()
print('YES')

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

Solution (Python):
from collections import defaultdict
d = defaultdict(list)
for i in range(3):
    a,b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

a = sorted([len(d[i]) for i in range(1,5)])
if a == [1,1,2,2]:
    print("YES")
else:print("NO")

Solution (Python):
k = []
for i in range(3):
    x,y = map(int,input().split())
    k.append(x)
    k.append(y)
if k.count(1) == 1 and k.count(2) == 2 and k.count(3) == 2 and k.count(4) == 1:
    print("YES")
else:
    print("NO")

Solution (Python):
G = [list(map(int,input().split())) for i in range(3)]
deg = [0]*4
for x in G:
    deg[x[0]-1] += 1
    deg[x[1]-1] += 1
odd = 0
for x in deg:
    if x%2 == 1:
        odd += 1
if odd == 0 or odd ==2:
    print("YES")
else:
    print("NO")

Solution (Python):
g = [[] for _ in range(4)]
for _ in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  g[b].append(a)
  
for i in range(4):
  if len(g[i]) != 1 and len(g[i]) != 2:
    print('NO')
    exit()
else:
  print('YES')

Solution (Python):
g = [[] for _ in range(4)]
for _ in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  g[b].append(a)
  
for i in range(4):
  if len(g[i]) != 1 and len(g[i]) != 2:
    print('NO')
    exit()
else:
  print('YES')

Solution (Python):
path = [list(map(int, input().split())) for _ in range(3)]
cnt = [0, 0, 0, 0]
for i in range(3):
    cnt[path[i][0] - 1] += 1
    cnt[path[i][1] - 1] += 1
if 3 in cnt:
    print("NO")
else:
    print("YES")

Solution (Python):
count = [0]*5
for i in range(3):
    a,b = [int(j) for j in input().split()]
    count[a]+=1
    count[b]+=1
for i in range(1,5):
    if count[i] == 3:
        print("NO")
        exit()
print("YES")

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

if (max(l) == 3)or(min(l) == 0):
    print("NO")
else:
    print("YES")

Solution (Python):
import collections as cl


def main() :
    bridges = []
    for i in range(3) :
        in_list = [int(i) for i in input().split()]
        bridges.extend(in_list)
    
    c = cl.Counter(bridges)
    com = c.most_common()
    if (com[0][1] == 2 and com[1][1] == 2 and com[2][1] == 1 and com[3][1] == 1) :
        print("YES")
    else :
        print("NO")
        
        
    






main()

Solution (Python):
def main():
    N = 4
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = (int(i) for i in input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    even, odd = 0, 0
    for e in edge:
        if len(e) % 2 == 1:
            odd += 1
        else:
            even += 1
    if odd == 2 and even == 2:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    A = [[int(i)-1 for i in input().split()] for j in range(3)]
    A.sort()
    if A[0] == A[1] or A[1] == A[2] or A[2] == A[0]:
        return print("NO")
    from collections import Counter
    c = Counter(sum(A, []))
    if [1, 1, 2, 2] == sorted(c.values()):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
import collections
a=collections.Counter(open(0).read().split())
v,c=zip(*a.most_common())
print("YES" if c[0]==c[1]==2 and c[2]==c[3]==1 else "NO")

Solution (Python):
def main():
    roads = [[] for _ in range(4)]
    for _ in range(3):
        a, b = map(lambda x: int(x) - 1, input().split())
        roads[a].append(b)
        roads[b].append(a)
    length = [0, 0, 0, 0]
    for r in roads:
        length[len(r)] += 1
    print("YES" if length == [0, 2, 2, 0] else "NO")


if __name__ == '__main__':
    main()

Solution (Python):
s=[list(map(int,input().split())) for i in range(3)]
res = [0]*4
for i in range(len(s)):
    res[s[i][0]-1] += 1
    res[s[i][1]-1] += 1

if max(res) > 2:
    print('NO')
else:
    print('YES')

Solution (Python):
c = [input().split() for i in range(3)]
c = sum(c, [])
for i in '1234':
    if c.count(i) > 2:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
s = [list(map(int, input().split())) for _ in range(3)]
flag = 0
cnt = 0
for i in range(1, 5):
    for j in s:
        if (j[0] == i) or (j[1] == i):
            cnt += 1
    if cnt == 3:
        flag = 1
        break
    else:
        cnt = 0
        continue

if flag == 1:
    print('NO')
else:
    print('YES')

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

if __name__ == "__main__":
    main()

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

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

for i in range(3):
    city[path[i][0]-1]=city[path[i][0]-1]-1
    city[path[i][1] - 1] = city[path[i][1] - 1] - 1
city.sort()
if (city[1]==-1)and(city[2]==0):
    print("YES")
else:
    print("NO")

Solution (Python):
ret = []
for i in range(3):
  ret+=list(map(int,input().split()))
ret.sort()
if ret.count(1)==3 or ret.count(2)==3 or ret.count(3)==3 or ret.count(4)==3:
  print('NO')
else:
  print('YES')

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

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

if max(ab) >= 3:
    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())
ab = [a1, a2, a3, b1, b2, b3]

if ab.count(1) >= 3 or ab.count(2) >= 3 or ab.count(3) >= 3 or ab.count(4) >= 3:
    print('NO')
else:
    print('YES')

Solution (Python):
road = []

road += input().split()
road += input().split()
road += input().split()

from collections import Counter

c = Counter(road)

flag = True
for k, v in c.items():
    if v > 2:
        flag = False

if flag:
    print("YES")
else:
    print("NO")

Solution (Python):
from collections import Counter
L=sorted(Counter(map(int, open(0).read().split())).values())
print("YNEOS"[any(i!=j for i,j in zip(L,[1,1,2,2]))::2])

Solution (Python):
dict = {"1":0, "2":0, "3":0, "4":0}
for i in range(3):
    a, b = input().split()
    dict[a] += 1
    dict[b] += 1

cnt = 0    
for value in dict.values():
    if(value >= 2):
        cnt += 1
print("YES" if cnt >= 2 else "NO")

Solution (Python):
dat = []
import collections
for i in range(3):
    a,b = map(int, input().split())
    dat.append(a)
    dat.append(b)
c = collections.Counter(dat)
res = []
for k in c:
    res.append(c[k])
res.sort()
if res == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    adj = [[] for _ in range(4)]
    visited = [False]*4
    for _ in range(3):
        x, y = get_list()
        adj[x-1].append(y-1)
        adj[y-1].append(x-1)
    def dfs(root):
        
        visited[root] = True
        for v in adj[root]:
            if not visited[v]:
                dfs(v)
                return
    dfs(0)
    print("YES") if False not in visited else print("NO")


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right

import math

out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()

print(*out, sep='\n')

Solution (Python):
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush




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




def main():
    dc=[2,0,0,0,0]
    no = 0
    for _ in range(3):
        a, b= lin()
        if a==b:
            no = 1
        dc[a]+=1
        dc[b]+=1
    print('YES' if max(dc)==2 and not no else 'NO')
    





        
main()