from itertools import combinations N, M = map(int, input().split()) edge = set() for _ in range(M): u, v = map(int, input().split()) edge.add((u, v)) edge.add((v, u)) abc = tuple(sorted(map(int, input().split()))) for comb in combinations(range(4), 3): if comb == abc: continue a, b, c = comb if (a, b) in edge and (b, c) in edge and (c, a) in edge: print("Yes") break else: if (0, 1) in edge and (1, 2) in edge and (2, 3) in edge and (3, 0) in edge: print("Yes") else: print("No")