import Control.Monad

main :: IO ()
main = do
  w <- readLn
  n <- readLn
  lots <- replicateM n $ do
    ln <- getLine
    let (a,b) = break (== ',') ln
    return $ (read a-1, read (tail b)-1)
  mapM_ print $ foldl (\acc (a,b) -> swap acc a b) [1..w] lots

swap :: [a] -> Int -> Int -> [a]
swap xs a b = foldr f [] $ zip [0..] xs
  where
    f (idx, v) acc
      | idx == a  = xs !! b : acc
      | idx == b  = xs !! a : acc
      | otherwise = v : acc