import sys from sys import stdin from collections import defaultdict def main(): N, M = map(int, stdin.readline().split()) adj = defaultdict(set) for _ in range(M): a, b = map(int, stdin.readline().split()) adj[a].add(b) adj[b].add(a) # Get neighbors of vertex 1 S = adj.get(1, set()) if not S: print("NO") return S_set = S # Using a set for O(1) lookups # Check all possible paths of the form 1 -> a -> b -> c -> d -> 1 for a in S: for b in adj[a]: if b == 1: continue # b is a neighbor of a (excluding 1) for c in adj[b]: if c == 1 or c == a: continue # c is a neighbor of b (excluding 1 and a) for d in adj[c]: if d == 1 or d == b: continue # d is a neighbor of c (excluding 1 and b) if d in S_set and d != a and d != c: print("YES") return print("NO") if __name__ == "__main__": main()