import Control.Monad
import Control.Applicative
import Data.List.Split

main :: IO ()
main = do
    w <- read <$> getLine
    n <- read <$> getLine
    x <- map ((\[a,b] -> (a,b)) . (map read) . (splitOn ",")) <$> replicateM n getLine
    mapM_ print $ solve x [1..w]

solve :: [(Int, Int)] -> [Int] -> [Int]
solve [] ls = ls
solve (x:xs) ls = solve xs $ swap a b ls
    where
        a = fst x - 1
        b = snd x - 1

swap 0 j xs'@(x:xs)= xs' !! j : take (j-1) xs ++ x:drop j xs
swap i j (x:xs) = x:swap (i-1) (j-1) xs