### BUGGY CODE ###

#!/usr/bin/env python3

import sys


class Node(object):
    def __init__(self, parent_id=-1, depth=0, children=[]):
        self.parent_id = parent_id
        self.depth = depth
        self.children = children

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    node_list = [None] * int(lines[0])  # Create empty list
    child_parent_map = [None] * int(lines[0])

    # Create the list of Node
    for line in lines[1:]:
        node_id, _, *children = [int(x) for x in line.strip().split(" ")]
        node_list[node_id] = Node(children=children)
        for child in children:
            child_parent_map[child] = node_id

    # Set the parent_id of each node
    for node_id, node in enumerate(node_list):
        if child_parent_map[node_id] is not None:
            node.parent_id = child_parent_map[node_id]

    # Set the depth of each node
    for node_id, node in enumerate(node_list):
        current_id = node_id
        current_depth = 0
        while True:
            if current_id == 0:
                node.depth = current_depth
                break
            else:
                current_id = node_list[current_id].parent_id
                current_depth += 1

    # Output
    for node_id, node in enumerate(node_list):
        if node_id == 0:
            node_type = "root"
        elif len(node.children) == 0:
            node_type = "leaf"
        else:
            node_type = "internal node"

        print("node %d: parent = %d, depth = %d, %s, %s" % (node_id, node.parent_id, node.depth, node_type, node.children))

### FIXED CODE ###

#!/usr/bin/env python3

import sys


class Node(object):
    def __init__(self, parent_id=-1, depth=0, children=[]):
        self.parent_id = parent_id
        self.depth = depth
        self.children = children

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    node_list = [None] * int(lines[0])  # Create empty list
    child_parent_map = [None] * int(lines[0])

    # Create the list of Node
    for line in lines[1:]:
        node_id, _, *children = [int(x) for x in line.strip().split(" ")]
        node_list[node_id] = Node(children=children)
        for child in children:
            child_parent_map[child] = node_id

    # Set the parent_id of each node
    for node_id, node in enumerate(node_list):
        if child_parent_map[node_id] is not None:
            node.parent_id = child_parent_map[node_id]

    # Set the depth of each node
    for node_id, node in enumerate(node_list):
        current_id = node_id
        current_depth = 0
        while True:
            # if current_id == 0:
            if node_list[current_id].parent_id == -1:
                node.depth = current_depth
                break
            else:
                current_id = node_list[current_id].parent_id
                current_depth += 1

    # Output
    for node_id, node in enumerate(node_list):
        if node.parent_id == -1:
            node_type = "root"
        elif len(node.children) == 0:
            node_type = "leaf"
        else:
            node_type = "internal node"

        print("node %d: parent = %d, depth = %d, %s, %s" % (node_id, node.parent_id, node.depth, node_type, node.children))