package main import ( "bufio" "fmt" "os" "strconv" ) func main() { N := nextInt() M := nextInt() pos := N for i := 1; i <= M; i++ { P := nextInt() Q := nextInt() switch pos { case P: pos = Q case Q: pos = P } } fmt.Println(pos) } var sc = bufio.NewScanner(os.Stdin) func next() string { sc.Split(bufio.ScanWords) sc.Scan() return sc.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i }