package main import "fmt" func main() { var n, m int fmt.Scan(&n, &m) s := [...]bool{false, false, false} s[n-1] = true for range make([]struct{}, m) { var p, q int fmt.Scan(&p, &q) s[p-1], s[q-1] = s[q-1], s[p-1] } for k, v := range s { if v == true { fmt.Println(k + 1) } } }