object Main extends app {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n, k, m) <- in if n != 0) {
        val s = (1 to n).toArray.updated(m-1, 0)
        val idx = (n-1 to 2 by -1).foldLeft(m-1)((i, len) => {
            val ss = s.zipWithIndex.filter(_._1 > 0)
            val start = { val j = ss.indexWhere(i < _._2); if (j == -1) 0 else j }
            val ii = ss((start+k-1)%len)._2
            s(ii) = 0
            ii
        })
        println(s.find(_ > 0).get)
    }
}