import Control.Applicative
import Data.Array.IArray
import Data.List (intercalate)
import Control.Monad

type MGraph = Array (Int, Int) Int

main = do
        n <- readLn
        fs <- replicateM n addNodeIO
        let arr = listArray ((1,1),(n,n)) $ repeat 0
            res = foldl (.) id fs arr
        putStrLn $ showGraph res

addNode :: Int -> [Int] -> MGraph -> MGraph
addNode n vs arr = arr // new
    where new = [((n,i), 1) | i <- vs]

addNodeIO :: IO (MGraph -> MGraph)
addNodeIO = do
        list <- words<$>getLine
        let list' = splitAt 1 list
            n = read.head.fst $ list'
            vs = map read.tail.snd $ list'
        return $ addNode n vs

showGraph arr = intercalate "\n" $ [unwords.map show $ [ arr ! (i,j) | j <- [hmin..hmax]] | i <- [vmin..vmax]]
        where ((vmin,hmin),(vmax,hmax)) = bounds arr