/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0011&lang=jp
  * Drawing Lots
  */
object Main {
  def main(args: Array[String]): Unit = {
    val w = io.StdIn.readInt()
    val n = io.StdIn.readInt()
    val hLines = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n)
      .map(_.split(",").map(_.toInt)).map { case Array(a, b) => (a, b) }
      .toList
    val vLines = 1 to w
    val playedVLines = playAmida(vLines, hLines)
    playedVLines.foreach(println)
  }

  def playAmida(vLines: Seq[Int], hLines: Seq[(Int, Int)]): Seq[Int] = {
    hLines.foldLeft(vLines) {
      case (v, h) => v.updated(h._1 - 1, v(h._2 - 1)).updated(h._2 - 1, v(h._1 - 1))
    }
  }

}