class Node
  attr_accessor :parent, :depth, :type, :child
  def initialize(parent, type)
    @parent = parent
    @type = type
    @depth = 0
    @child = []
  end
end

def setdepth(tree, depth, child)
  if child.size != 0 then
    child.each{|i|
      tree[i].depth = depth
      setdepth(tree, depth+1, tree[i].child)
    }
  end
end
n = gets.to_i
tree = Array.new(n){Node.new(-1, "leaf")}
n.times{
  i, m, *child = gets.split.map(&:to_i)
  if m > 0 then
    tree[i].type = "internal node"
    child.each{|j|
      tree[j].parent = i
    }
    tree[i].child = child
  end
}

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


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