class RootedTree
  def solve
    n  = gets.chomp.to_i
    nd = Array.new

    n.times do
      i = gets.split(/\s/).map(&:to_i)
      if i[1] == 0
        unless nd[i[0]]
          nd[i[0]] = [nil, nil]
        end
      else
        if(nd[i[0]])
          nd[i[0]][1] = i[2,i[1]]
        else
          nd[i[0]] = [nil, i[2,i[1]]]
        end
        (1..i[1]).each do |x|
          if(nd[i[x+1]])
            nd[i[x+1]][0] = i[0]
          else
            nd[i[x+1]] = [i[0], nil]
          end
        end
      end
    end

    (0...n).each do |i|
      depth = 0
      prt = nd[i][0]
      while (prt)
        depth += 1
        prt = nd[prt][0]
      end
      print "node #{i}: parent = #{nd[i][0] ? nd[i][0] : -1}, depth = #{depth}, #{nd[i][0] ? (nd[i][1] ? "internal node" : "leaf") : "root"}, "
      print "["
      if nd[i][1]
        print "#{nd[i][1].join(", ")}"
      end
      puts "]"
    end
  end
end

if $0 == __FILE__
  RootedTree.new.solve
end