#binary_tree
class Node
  attr_accessor :myname,:parent,:left,:right,:depth,:height

  def initialize(n)
    @myname = n
    @parent = nil
    @left   = nil
    @right  = nil
    @depth  = 0
  end

  def add_left(child)
      self.left    = child
      child.parent = self
  end

  def add_right(child)
      self.right    = child
      child.parent = self
  end

  def set_depth(d)
    self.depth = d
    if(self.left != nil)
      self.left.set_depth(d+1)
    end
    if(self.right != nil)
      self.right.set_depth(d+1)
    end
  end

  def set_height
    if(self.left != nil)
      lh=self.left.set_height
    else
      lh=0
    end
    if(self.left != nil)
      rh=self.right.set_height
    else
      rh=0
    end
    if lh > rh 
      self.height = lh + 1
    else
      self.height = rh + 1
    end
  end

  def sibling
    p = self.parent
    if p == nil
      nil
    elsif self == p.left
      p.right
    else
      p.left
    end
  end

  def degree
    deg=0
    if self.left != nil
      deg += 1
    end
    if self.right != nil
      deg += 1
    end
    deg
  end

  def shubetu

    if self.parent == nil
      "root"
    elsif self.height == 1
      "leaf"
    else
      "internal node"
    end

  end

  def describe
    printf("node %d:",self.myname)
    if self.parent == nil 
      printf(" parent = -1,")
    else
      printf(" parent = %d,",self.parent.myname)
    end
    if self.sibling == nil 
      printf(" sibling = -1,")
    else
      printf(" sibling = %d,",self.sibling.myname)
    end
    printf(" degree = %d,",self.degree)
    printf(" depth = %d,",self.depth)
    printf(" height = %d,",self.height-1)
    printf(" %s\n",self.shubetu)
  end
end


$n = STDIN.gets.split[0].to_i
$tree=Array.new($n){|i| Node.new(i)}

0.upto($n-1){|i|
  s = STDIN.gets.split
  id= s[0].to_i
  l = s[1].to_i
  r = s[2].to_i

#  printf("%d %d %d:\n",id,l,r)
  if(l != -1)
    $tree[id].add_left($tree[l])
  end
  if(r != -1)
    $tree[id].add_right($tree[r])
  end
}


def findroot
  0.upto($n-1){|i|
    if $tree[i].parent == -1 
      return i
    end
  }
end

#rt = findroot
rt=0
$tree[rt].set_depth(0)
$tree[rt].set_height

0.upto($n-1){|i|
  $tree[i].describe 
}