n = gets.to_i
$lst = Array.new(n)
parent = Array.new(n, -1)
$depth = Array.new(n, 0)
def dps(i, dep)
  if $lst[i].size == 0
    $depth[i] = dep
    return
  end
  $lst[i].each{ |j| dps(j,dep+1) }
  $depth[i] = dep
  return
end
n.times do
  l = gets.split.map(&:to_i)
  id = l.shift
  l.shift
  l.each { |i| parent[i] = id }
  $lst[id] = l
end
n.times{ |i| dps(i,0) if parent[i] == -1 }
n.times do |i|
  s = ""
  if parent[i] == -1 then s = "root"
  elsif $lst[i].size == 0 then s = "leaf"
  else s = "internal node"
  end
  puts "node #{i}: parent = #{parent[i]}, depth = #{$depth[i]}, #{s}, #{$lst[i]}"
end