import Control.Applicative
import Control.Monad
import Data.Array.IArray


main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- replicateM n $ do
    (a:_:ns) <- getInts
    return $ zip (zip (repeat a) ns) (repeat 1)
  mapM_ putStrLn $
    format $ solve n $ concat ns

getInts :: IO [Int]
getInts = map read . words <$> getLine

format :: Array (Int, Int) Int -> [String]
format arr = let ((_, _), (n, _)) = bounds arr in
               do
                 i <- [1..n]
                 let ns =
                       do
                         j <- [1..n]
                         return $ arr ! (i, j)
                 return $
                   unwords (map show ns)
                 
solve :: Int -> [((Int, Int), Int)] -> Array (Int, Int) Int
solve n ns = accumArray f 0 ((1, 1), (n, n)) ns
  where
    f :: Int -> Int -> Int
    f _ _ = 1