import Control.Monad (fmap, replicateM)
import Data.Array (listArray, elems, (//), (!))
import Data.List (foldl')

main = input >>= output . solve

input :: IO (Int, [(Int, Int)])
input = do
    w <- readLn
    n <- readLn
    ps <- map toPair `fmap` replicateM n getLine
    return (w,ps)
    where
    toPair s = (read a, read b)
        where
        (a,(_:b)) = break (==',') s

output :: [Int] -> IO ()
output ns = mapM_ print ns

solve :: (Int, [(Int, Int)]) -> [Int]
solve (w,ps) = elems $ foldl' applySwap (listArray (1,w) [1..]) ps
    where
    applySwap ns (a,b) = ns // [(a,ns!b), (b,ns!a)]