import Control.Monad (replicateM) import Data.Char (isSpace) import Data.List (transpose, unfoldr) import qualified Data.ByteString.Char8 as BSC8 getL :: (BSC8.ByteString -> [Int]) -> IO [Int] getL f = f <$> BSC8.getLine readIL :: (BSC8.ByteString -> Maybe (Int, BSC8.ByteString)) -> (BSC8.ByteString -> [Int]) readIL f = unfoldr g where g s = do (n, s') <- f s return (n, BSC8.dropWhile isSpace s') main :: IO () main = do n <- readLn :: IO Int xss <- replicateM n $ getL (readIL BSC8.readInt) putStrLn $ unwords $ map show $ concat $ transpose $ map tail xss