import sys from collections import defaultdict def main(): N, M = map(int, sys.stdin.readline().split()) adj = defaultdict(list) for _ in range(M): u, v = map(int, sys.stdin.readline().split()) adj[u].append(v) adj[v].append(u) # Collect neighbors of 1 S = adj[1] if len(S) < 2: print("NO") return # Precompute for each y, the set of S nodes connected to y pre = defaultdict(set) for z in S: for y in adj[z]: pre[y].add(z) # Iterate through each a in S for a in S: # Iterate through each neighbor x of a, excluding 1 for x in adj[a]: if x == 1: continue # Iterate through each neighbor y of x, excluding a for y in adj[x]: if y == a: continue # Check if y has any S nodes connected to it if pre[y]: # Check if any of those S nodes is not a has_valid = False for z in pre[y]: if z != a: has_valid = True break if has_valid: print("YES") return print("NO") if __name__ == "__main__": main()