class Node
  attr_accessor :node, :left_child, :right_sibling, :parent, :depth, :children, :type
  def initialize(node)
    @node = node
    @parent = -1
    @children = []
  end

  def get_depth
    depth = 0
    u = node
    until @@tree[u].parent == -1 do
      depth += 1
      u = @@tree[u].parent
    end
    depth
  end

  def get_children
    if left_child.nil?
      []
    else
      u = left_child
      children = [u]
      until @@tree[u].right_sibling == nil do
        u = @@tree[u].right_sibling
        children << u
      end
      children
    end
  end

  def get_type
    # p self.get_children
    case
    when parent == -1
      'root'
    when children == []
      'leaf'
    else
      'internal node'
    end
  end
end

n = gets.to_i

@@tree = {}

n.times do
  input = gets.split.map(&:to_i)
  id = input[0]
  children_count = input[1]
  children = input[2..-1] if children_count != 0

  @@tree[id] ||= Node.new(id)
  node = @@tree[id]
  if children_count == 0
    node.left_child = nil
  else
    node.left_child = children[0]

    children.push(nil).each_cons(2) do |a, b|
      @@tree[a] ||= Node.new(a)
      @@tree[a].parent = id
      @@tree[a].right_sibling = b if b
    end
  end
  node.depth = node.get_depth
  node.children = children if children
  puts "node #{node.node}: parent = #{node.parent}, depth = #{node.depth}, #{node.get_type}, #{node.children}"
end

