main = do
    n <- readLn
    lines <- replicateM n getLine
    putStr $ unlines $ map (unwords . listToMatrics n . lineToIntList) lines
    where
      -- lineToIntList::String -> [Int]
      lineToIntList line =
        map read $ words line

      -- listToMatrics::Int -> [Int] -> [Int]
      listToMatrics n (_:_:vs) =
        let
          -- transposeTo::Int->[Int]->[Int]
          transposeTo n xs=
            map (\_ -> n) xs

          p m [] xs =
            m ++ transposeTo "0" xs

          p m (v:vs) xs = 
            let
              (b,a) = span (\x -> v /= x) xs
            in
              p (m ++ transposeTo "0" b ++ ["1"]) vs (tail a)

        in
          p [] vs [1..n]