package main import ( "fmt" ) func resolve(N, M int, P, Q []int) int { ret := N for i := 0; i < M; i++ { switch { case P[i] == ret: ret = Q[i] case Q[i] == ret: ret = P[i] } } return ret } func main() { var N, M int fmt.Scanf("%d\n%d\n", &N, &M) P := make([]int, M) Q := make([]int, M) for i := 0; i < M; i++ { fmt.Scanf("%d %d\n", &P[i], &Q[i]) } fmt.Println(resolve(N, M, P, Q)) }