Tree = {}
Parents = {}
n = gets.to_i
n.times do
  i, _, *c = gets.split(' ').map(&:to_i)
  c.each do |m|
    Parents[m] = i
  end
  Tree[i] = c
end
Tree.sort.each do |i, n|
  if Parents[i].nil?
    t = 'root'
  elsif n.empty?
    t = 'leaf'
  else
    t = 'internal node'
  end
  p = t == 'root' ? -1 : Parents[i]
  depth = -> (d, j) do
    return d if Parents[j].nil?
    return depth.(d + 1, Parents[j])
  end
  puts "node #{i}: parent = #{p}, depth = #{depth.(0, i)}, #{t}, #{n.inspect}"
end
