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

swapElem :: Int -> Int -> [a] -> [a]
swapElem i j xs = let xi = xs !! i
                      xj = xs !! j
                      left  = take i xs
                      mid   = take (j - i - 1) (drop (i + 1) xs)
                      right = drop (j + 1) xs
                  in  left ++ [xj] ++ mid ++ [xi] ++ right

solve :: Int -> [(Int, Int)] -> [Int]
solve w = foldl (\acc (a, b) -> swapElem (a - 1) (b - 1) acc) [1..w]

nyan :: String -> (Int, Int)
nyan = tup . words . map c2s
  where c2s c = if c == ',' then ' ' else c
        tup (a:b:_) = (read a, read b)

main :: IO ()
main = do
  w <- readLn
  n <- readLn
  xs <- map nyan <$> replicateM n getLine
  mapM_ print $ solve w xs