n = gets.to_i
nodes = []
children = Array.new(n, [])
parents = Array.new(n, -1)
depth = Array.new(n, nil)

n.times do |i|
  l = gets.chomp.split.map(&:to_i)
  nodes << l
  node = l.first
  if l[1].zero?
    next
  else
    children[node] = l[2..-1]
  end
end

children.each.with_index do |child, i|
  next if child == -1
  child.each do |c|
    parents[c] = i
  end
end

d = 0
root = parents.select{ |x| x == -1}.first
current = [parents.index(root)]
while depth.any?(&:nil?)
  current.each { |c| depth[c] = d }
  temp = []
  current.each { |c| children[c].each { |x| temp << x } }
  current = temp
  d += 1
end

0.upto(n-1) do |i|
  print "node #{i}: parent = #{parents[i]}, depth = #{depth[i]}"
  if children[i].empty?
    puts ", leaf, []"
  elsif parents[i] == -1
    print ", root, "
    p children[i]
  else
    puts ", internal node, #{children[i]}"
  end
end