import Data.List

main = interact $ unlines . map (show . attwo . map read . words) . init . lines

attwo [n,k,m] = attwo' (n-1) $ take (n-1) $ tail $ dropWhile (/=m) (cycle [1..n])
 where
  attwo' _ [x] = x
  attwo' l xs = attwo' (l-1) (delete x (take l xs'))
   where (x:xs') = drop (mod (k-1) l) (cycle xs)