def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 M = int(input[idx]) idx += 1 adj = [set() for _ in range(N + 1)] for _ in range(M): u = int(input[idx]) idx += 1 v = int(input[idx]) idx += 1 adj[u].add(v) adj[v].add(u) S = adj[1] if not S: print("NO") return # Precompute S as a set for faster lookups S_set = S for x in S: # Iterate through all a adjacent to x (excluding 1 and x) for a in adj[x]: if a == 1 or a == x: continue # Iterate through all b adjacent to a (excluding 1, x, a) for b in adj[a]: if b == 1 or b == x or b == a: continue # Iterate through all y adjacent to b (check if y is in S and not x, a, b) for y in adj[b]: if y in S_set and y not in {x, a, b}: print("YES") return print("NO") if __name__ == "__main__": main()