package main import ( "fmt" ) func main() { var N, M, s, d int _, _ = fmt.Scan(&N, &M) for i := 0; i < M; i++ { _, _ = fmt.Scan(&s, &d) if s == N { N = d } else if d == N { N = d } } fmt.Println(N) }