#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin

FORMAT = ('node {0.id}: parent = {0.parent}, sibling = {0.sibling}, '
          'degree = {0.degree}, depth = {0.depth}, height = {0.height}, '
          '{0.type}').format


class Node(object):
    def __init__(self, data):
        self.id = data[0]
        self.parent = -1
        self.sibling = -1
        self.degree = int(data[1] > 0) + int(data[2] > 0)
        self.childs = [i for i in data[1:] if i > 0]
        self.depth = 0
        self.height = -1
        self.type = 'internal node' if self.degree else 'leaf'

    def __str__(self):
        return FORMAT(self)


def calc_depth(tree, i):
    h = 0
    for k, j in enumerate(tree[i].childs):
        tree[j].depth += 1
        tree[j].sibling = tree[i].childs[1-k]
        h = max(h, calc_depth(tree, j))
    if tree[i].type == 'leaf':
        tree[i].height = 0
    else:
        tree[i].height = h
    return tree[i].height + 1


n = int(stdin.readline())
tree = [-1] * n

for _ in range(n):
    node = Node([int(s) for s in stdin.readline().split()])
    parent = tree[node.id]
    tree[node.id] = node
    if isinstance(parent, int):
        tree[node.id].parent = parent
    else:
        tree[node.id].parent = parent.id
    for i in node.childs:
        if isinstance(tree[i], int):
            tree[i] = node.id
        else:
            tree[i].parent = node.id

for i in range(n):
    calc_depth(tree, i)

for node in tree:
    if node.parent == -1:
        node.type = 'root'
    print(node)

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin

FORMAT = ('node {0.id}: parent = {0.parent}, sibling = {0.sibling}, '
          'degree = {0.degree}, depth = {0.depth}, height = {0.height}, '
          '{0.type}').format


class Node(object):
    def __init__(self, data):
        self.id = data[0]
        self.parent = -1
        self.sibling = -1
        self.degree = int(data[1] >= 0) + int(data[2] >= 0)
        #self.childs = [i for i in data[1:] if i > 0]
        self.childs = data[1:]
        self.depth = 0
        self.height = -1
        self.type = 'internal node' if self.degree else 'leaf'

    def __str__(self):
        return FORMAT(self)


def calc_depth(tree, i):
    h = 0
    for k, j in enumerate(tree[i].childs):
        if j >= 0:
            tree[j].depth += 1
            tree[j].sibling = tree[i].childs[1-k]
            h = max(h, calc_depth(tree, j))
    if tree[i].type == 'leaf':
        tree[i].height = 0
    else:
        tree[i].height = h
    return tree[i].height + 1


n = int(stdin.readline())
tree = [-1] * n

for _ in range(n):
    node = Node([int(s) for s in stdin.readline().split()])
    parent = tree[node.id]
    tree[node.id] = node
    if isinstance(parent, int):
        tree[node.id].parent = parent
    else:
        tree[node.id].parent = parent.id
    for i in node.childs:
        if i >= 0:
            if isinstance(tree[i], int):
                tree[i] = node.id
            else:
                tree[i].parent = node.id

for i in range(n):
    calc_depth(tree, i)

for node in tree:
    if node.parent == -1:
        node.type = 'root'
    print(node)