{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveFoldable             #-}
{-# LANGUAGE DeriveFunctor              #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoMonomorphismRestriction  #-}
{- |
   Module      : ALDS1_11_A
   Description : The "ALDS1_11_A" module
   Copyright   : (c) kiripon
   License     : BSD-style (see the file LICENSE)
 -}
module Main where
import Control.Applicative
import qualified Data.Array.IO as IOArray
import Control.Monad
getInts :: IO [Int]
getInts = map read . words <$> getLine
main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- IOArray.newArray ((1,1),(n,n)) (0 :: Int) :: IO (IOArray.IOArray (Int,Int) Int)
  replicateM_ n $ do
    i:_:xs <- getInts
    forM_ xs $ \to -> do
      IOArray.writeArray a (i,to) 1
  forM_ [(x,y) | x <- [1..n], y <- [1..n]] $ \(x,y) -> do
    v <- IOArray.readArray a (x,y)
    if y == n
      then print v
      else putStr $ show v ++ " "
  return ()