class Node
  attr_accessor :id, :parent, :children, :depth

  def initialize(n)
    @id = n
    @parent = -1   # 初期値-1, add_childで上書き
    @children = []
  end

  def add_child(child)
    @children << child
    child.parent = self
  end
  
  def set_depth(n)
    @depth = n
    @children.each do | c |
      c.set_depth(n+1)
    end
  end

  def to_s; "#{@id}"; end

  def type
    if self.parent == -1
      "root"
    elsif children.size > 0
      "internal node"
    else
      "leaf"
    end
  end

  def children_id
    s = '['
    @children.each_with_index do | c,i |
      s += "#{c.id}"
      s += ', ' if i != @children.size - 1
    end
    s += ']' 
  end

end

n = gets.to_i
kcs = n.times.map{ gets.split.map(&:to_i) }

tree = Array.new(n){ | i | Node.new(i) }

kcs.each do | kc |
  id = kc.shift; kc.shift
  kc.each do | c |
    tree[id].add_child(tree[c])
  end
end

# nodeを作ってく中でdepthを設定すると, node:0から
# 読み込まれなかった場合にerr
root = nil;
tree.each{ |node| root = node if node.parent == -1}
root.set_depth(0)

tree.each do | c, i |
  print "node #{c.id}: "
  print "parent = #{c.parent}, "
  print "depth = #{c.depth}, "
  print "#{c.type}, "
  print "#{c.children_id}"
  puts ''
end

