let swap a i j = let x = a.(i) and y = a.(j) in a.(i) <- y;a.(j) <-x;;

let w = read_int () and
    n = read_int () in
    let a = Array.init w (fun x->(x+1)) in
    for i = 1 to n do
      let (x,y) = Scanf.scanf "%d,%d\n" (fun x y->(x,y)) in swap a (x-1) (y-1);
    done;
    Array.iter (fun k -> Printf.printf "%d\n" k) a;;