object Main extends App {
  val src: List[List[Int]] = io.Source.stdin.getLines.map(_.split(",").toList.map(_.toInt)).toList
  val org: List[Int] = List.range(1, src.head(0) + 1)
  val operations: List[List[Int]]= src.drop(2)

  def func(org: List[Int], li: List[Int]): List[Int] = {
    org.updated(li(0)-1, org(li(1)-1)).updated(li(1)-1, org(li(0)-1))
  }

  ((org /: operations)(func)).foreach(println)
}