use std::io; fn main() { let v = input_nums(); let n = v[0]; let v = input_nums(); let m = v[0]; let mut target = n; for _i in 0..m { let v = input_nums(); if v[0] == target { target = v[1]; } else if v[1] == target { target = v[0]; } } println!("{}", target); } fn input_nums() -> Vec { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let mut v = Vec::new(); for n in s.split_whitespace() { v.push(n.parse().unwrap()); } v }