def read_data(): N, M = map(int, input().split()) Es = [set() for i in range(N)] for i in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 Es[a].add(b) Es[b].add(a) return N, M, Es def solve(N, M, Es): ''' Es に頂点0を含む長さ5 の単純閉路が存在するか否かを返す。 ''' d1 = Es[0] d2 = set() for d1i in d1: d2 |= Es[d1i] bss = [d1 & Esb for Esb in Es] for c in d2: for d in Es[c]: if d in d2: if is_valid(c, d, bss): return True return False def is_valid(c, d, bss): bs = bss[c] - {d} es = bss[d] - {c} if not bs: return False if not es: return False if len(bs | es) < 2: return False return True N, M, Es = read_data() if solve(N, M, Es): print("YES") else: print("NO")