import sequtils, strutils, math, algorithm when not declared ATCODER_READER_HPP: const ATCODER_READER_HPP* = 1 import streams, strutils, sequtils # proc scanf*(formatstr: cstring){.header: "", varargs.} #proc getchar(): char {.header: "", varargs.} # proc nextInt*(): int = scanf("%lld",addr result) # proc nextFloat*(): float = scanf("%lf",addr result) proc nextString*(f:auto = stdin): string = var get = false result = "" while true: let c = f.readChar #doassert c.int != 0 if c.int > ' '.int: get = true result.add(c) elif get: return proc nextInt*(f:auto = stdin): int = parseInt(f.nextString) proc nextFloat*(f:auto = stdin): float = parseFloat(f.nextString) # proc nextString*():string = stdin.nextString() proc toStr*[T](v:T):string = proc `$`[T](v:seq[T]):string = v.mapIt($it).join(" ") return $v proc print0*(x: varargs[string, toStr]; sep:string):string{.discardable.} = result = "" for i,v in x: if i != 0: addSep(result, sep = sep) add(result, v) result.add("\n") stdout.write result var print*:proc(x: varargs[string, toStr]) print = proc(x: varargs[string, toStr]) = discard print0(@x, sep = " ") let N = nextInt() let M = nextInt() var g = newSeqWith(N, newSeq[int](N)) for i in 0 ..< M: let i = nextInt() let j = nextInt() g[i][j] = 1 g[j][i] = 1 var s = 0 for i in 0 ..< 3: s = s or (1 shl nextInt()) for i in 1 ..< (1 shl N): if i != s: var p = newSeq[int]() for j in 0 ..< N: if (i and (1 shl j)) > 0: p.add(j) if len(p) <= 2: continue var q = (0 ..< len(p)).toSeq var qnx = newSeq[seq[int]]() while true: qnx.add(q) if q.nextPermutation() == false: break for q in qnx: var ok = true for j in 0 ..< len(p): if g[p[q[j]]][p[q[(j + 1) mod len(p)]]] == 0: ok = false if ok: echo "Yes" quit(0) echo "No"