module Main where

    -- import Debug.Trace
    import Data.List
    import qualified Data.Sequence as S
    import qualified Data.ByteString.Char8 as B
    import Data.Int
    import Data.Char
    import Data.Array
    -- import Data.Array.IO
    import Data.Maybe
    import qualified Data.Map as M
    import Data.Ord
    import Data.Functor
    import Control.Applicative
    import Control.Monad
    import Text.Printf
     
    solve :: Int -> [[Int]] -> Array (Int, Int) Int
    solve n l = accumArray (+) 0 ((1,1), (n,n)) (vertices l) where
        vertices [] = []
        vertices (l:ls) = adjacents l ++ vertices ls
        adjacents (k:n:as) = iter as where
            iter [] = []
            iter (a:as) = ((k, a),1):iter as

    readIntLn:: IO Int
    readIntLn = (fst . fromJust . B.readInt) <$> B.getLine
    
    readIntList:: IO [Int]
    readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

    print' :: Int -> Array (Int, Int) Int -> IO()
    print' n ar = iterI 1 where
        iterI i 
            | i > n = return ()
            | otherwise = iterJ 1 >> iterI (i+1) where
                iterJ j 
                    | j < n = putStr (s ++ " ") >> iterJ (j+1)
                    | otherwise = putStrLn s where
                        s = show $ ar!(i,j)
     
    main :: IO() 
    main = do
        n <- readIntLn
        l <- replicateM n readIntList
        print' n $ solve n l
    
