class Node
  attr_accessor :parent, :sibling, :depth, :degree, :height, :type, :child
  def initialize()
    @parent = -1
    @sibling = -1
    @degree = 0
    @depth = 0
    @height = 0
    @type = "leaf"
    @child = []
  end
end

def set_depth_height(tree, depth, child)
  if child.size != 0 then
    height = 0
    child.each{|i|
      tree[i].depth = depth
      h = set_depth_height(tree, depth+1, tree[i].child)
      tree[i].height = h
      height = h if height < h
    }
    return height + 1
  else
    return 0
  end
end

n = gets.to_i
tree = Array.new(n){Node.new()}

n.times{
  i, l, r = gets.split.map(&:to_i)
  if l != -1 then
    tree[i].type = "internal node"
    tree[i].degree = 2
    tree[i].child = [l, r]
    tree[l].parent = i
    tree[l].sibling = r
    tree[r].parent = i
    tree[r].sibling = l
  end
}

#find root
0.upto(n-1){|i|
  if tree[i].parent == -1 then
    tree[i].type = "root"
    tree[i].depth = 0
    #calc depth
    tree[i].height = set_depth_height(tree, 1, tree[i].child);
    break
  end
}

0.upto(n-1){|i|
  printf "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, tree[i].parent, tree[i].sibling, tree[i].degree, tree[i].depth, tree[i].height, tree[i].type
}