import Data.List

main :: IO()
main = getContents >>= putOut.formatOut.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s

formatIn :: String -> [Int]
formatIn = map read.words.(!!1).lines

formatOut :: [[Int]] -> String
formatOut = unlines.map (unwords.(map show))

solve    :: [Int] -> [[Int]]
solve xs = zipWith (((\(x,y)-> sort x ++ y ).).splitAt)  [1..length xs] $repeat xs