from sys import stdin def main(): input = stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 m = int(input[idx]) idx += 1 adj = [[] for _ in range(n + 1)] for _ in range(m): u = int(input[idx]) idx += 1 v = int(input[idx]) idx += 1 adj[u].append(v) adj[v].append(u) # Collect neighbors of vertex 1 s = set() for neighbor in adj[1]: s.add(neighbor) if not s: print("NO") return found = False # Check each neighbor of 1 for a in s: # DFS stack: (current node, depth, visited set) stack = [(a, 0, {1, a})] while stack: node, depth, visited = stack.pop() if depth == 3: if node in s and node != a: found = True break continue # Explore neighbors in reverse order to process smaller indices first (stack order) for neighbor in reversed(adj[node]): if neighbor == 1: continue if neighbor not in visited: new_visited = visited.copy() new_visited.add(neighbor) stack.append((neighbor, depth + 1, new_visited)) if found: break print("YES" if found else "NO") if __name__ == "__main__": main()