import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val n = (1 to readInt).toArray
  val m = readInt
  for(i <- 1 to m) {
    val h = readLine.split(",").map(_.toInt)
    val temp = n(h(0)-1)
    n(h(0)-1) = n(h(1)-1)
    n(h(1)-1) = temp
  }
  n.foreach(println)
}