Tree = {}
Parents = {}
Siblings = {}

n = gets.to_i
n.times do
  i, l, r = gets.split(' ').map(&:to_i)
  Parents[l] = Parents[r] = i
  Siblings[l] = r
  Siblings[r] = l
  Tree[i] = [l, r]
end

Parents[-1] = nil

Tree.sort.each do |i, n|
  p = Parents[i]
  s = Siblings[i]
  if Parents[i].nil?
    t = 'root'
    p = -1
    s = -1
  elsif n == [-1, -1]
    t = 'leaf'
  else
    t = 'internal node'
  end

  depth = -> (d, j) do
    return d if Parents[j].nil?
    return depth.(d + 1, Parents[j])
  end

  height = -> (h, n) do
    return h if n == -1
    return [height.(h + 1, Tree[n][0]), height.(h + 1, Tree[n][1])].max
  end

  d = depth.(0, i)
  h = [height.(0, n[0]), height.(0, n[1])].max
  g = n.select{|c| c != -1}.size

  puts "node #{i}: parent = #{p}, sibling = #{s}, degree = #{g}, depth = #{d}, height = #{h}, #{t}"
end
