import Control.Applicative
import Control.Monad

main = do
    n <- readLn
    lines <- replicateM n getLine
    mapM_ (listToMatrics n . map read . words) lines
    where
      listToMatrics n (u:k:vs) = do
        p vs [1..n]

      p [] xs = do
        mapM_ (\x -> putStr "0 ") xs
        putStrLn ""

      p (v:vs) xs = do
        (b,a) <- fmap (span (\x -> v /= x)) $ return xs
        mapM_ (\x -> putStr "0 ") b
        putStr "1 "
        p vs (tail a)