let _ =
  let w = Scanf.scanf "%d\n" (fun x -> x) in
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let ar = Array.init w (fun x -> x + 1) in
  let swap ar i j = 
    let t = ar.(i-1) in
    ar.(i-1) <- ar.(j-1);
    ar.(j-1) <- t in
  for i = 1 to n do
    let a,b = Scanf.scanf "%d,%d\n" (fun x y -> (x, y)) in
    swap ar a b
  done;
  Array.iter (fun x -> Printf.printf "%d\n" x) ar