# depth
depth = gets.chomp.to_i

class Node
  attr_reader :id, :left, :right
  attr_accessor :height, :parent, :sibling, :depth, :height
  def initialize(id, left, right, depth)
    @id     = id
    @left   = left
    @right  = right
    @parent = -1
    @height = depth
    @depth  = 0
    @sibling = -1
  end

end


req = {}
num = (0..depth-1).to_a
c_list = (0..depth-1).to_a
num.each do |i|
  stdin = gets.chomp.split.map(&:to_i)
  id    = stdin[0]
  left  = stdin[1]
  right = stdin[2]

  c_list.delete(left) { c_list}
  c_list.delete(right){ c_list}
  req[id] = Node.new(id, left, right, depth)
end

id = c_list.shift



leafs = []
def calch(req, node, height, pid, sib, leafs)
  node.parent = pid
  node.sibling = sib

  lnode = req[node.left]
  rnode = req[node.right]
  return nil if node.nil?
  lid = lnode.id
  rid = rnode.id

  height += 1
  pid = node.id
  lh = calch(req, lnode, height, pid, rid, leafs)
  rh = calch(req, rnode, height, pid, lid, leafs)
  
  if lh <= rh
    rh 
  else 
    lh
  end
end
h = calch(req, req[id], 0, -1, -1, leafs)
def markd(req, node, h, d)
  return nil if node.nil?
  
  if node.left == -1
    node.height = -1
  else
  node.height = h
  end
  node.depth = d

  markd(req, req[node.left], (h - 1), (d + 1))
  markd(req, req[node.right], (h - 1), (d + 1))
end

markd(req, req[id], h, 0)


num.each do |i|
  node = req[i]
  if node.left == -1
    type = 'leaf'
    degree = 0
  else
    type = 'internal node'
    degree = 2
  end
  type = 'root' if node.parent == -1
  puts "node #{i}: parent = #{node.parent}, sibling = #{node.sibling}, degree = #{degree}, depth = #{node.depth}, height = #{node.height}, #{type}"
end