object Main extends App {
    val Array(n) :: _ :: s = io.Source.stdin.getLines.map(_.split(",").map(_.toInt)).toList
    s.foldLeft((1 to n).toList){case (x, Array(a, b)) =>
        x.updated(a-1, x(b-1)).updated(b-1, x(a-1))
    }.foreach(println)
}