import sys from sys import stdin def main(): sys.setrecursionlimit(1 << 25) N, M = map(int, stdin.readline().split()) adj = [set() for _ in range(N + 1)] for _ in range(M): u, v = map(int, stdin.readline().split()) adj[u].add(v) adj[v].add(u) S = adj[1] if len(S) < 2: print("NO") return # Precompute neighbors_in_S for each node neighbors_in_S = [set() for _ in range(N + 1)] for node in S: for neighbor in adj[node]: neighbors_in_S[neighbor].add(node) for a in S: two_step = set() # Iterate over neighbors of a, excluding 1 and a itself for b in adj[a]: if b == 1 or b == a: continue # Iterate over neighbors of b, excluding 1, a, and b for c in adj[b]: if c == 1 or c == a or c == b: continue two_step.add(c) # Check each c in two_step for c in two_step: s = neighbors_in_S[c] if not s: continue if a not in s or len(s) >= 2: print("YES") return print("NO") if __name__ == "__main__": main()