import sys



class Node:

    def __init__(self):

        self.id = 0

        self.parent = -1

        self.depth = 0

        self.type = "root"

        self.children = []



def addDepth(id, tree):

    tree[id].depth += 1

    for child in tree[id].children:

        addDepth(child, tree)



if __name__ == "__main__":

    lines = sys.stdin.readlines()

    N = int(lines[0])

    del lines[0]



    tree = []

    for i in range(N):

        tree.append(Node())



    for line in lines:

        line = list(map(int, line.split()))

        tree[line[0]].id = line[0]

        tree[line[0]].children = line[2:]



    for node in tree:

        for child in node.children:

            tree[child].parent = node.id

            addDepth(child, tree)

            if tree[child].children:

                tree[child].type = "internal node"

            else:

                tree[child].type = "leaf"



    for node in tree:

        print("node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format(node))
import sys



class Node:

    def __init__(self):

        self.id = -1

        self.parent = -1

        self.type = "leaf"



    def printInfo(self):

        print("node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format(self))



def setTree(id, tree, depth):

    tree[id].depth = depth

    if not tree[id].children:

        return



    for child in tree[id].children:

        tree[child].parent = id

        setTree(child, tree, depth + 1)

    tree[id].type = "internal node"



if __name__ == "__main__":

    lines = sys.stdin.readlines()

    N = int(lines[0])

    del lines[0]



    tree = []

    for i in range(N):

        tree.append(Node())



    root = N * (N - 1) / 2

    for line in lines:

        info = list(map(int, line.split()))

        tree[info[0]].children = info[2:]

        tree[info[0]].id = info[0]

        for i in tree[info[0]].children:

            root -= i



    setTree(root, tree, 0)

    tree[root].type = "root"



    for node in tree:

        node.printInfo()
import sys


class Node:
    def __init__(self):
        self.id = 0
        self.parent = -1
        self.depth = 0
        self.type = "root"
        self.children = []


def addDepth(id, tree):
    tree[id].depth += 1
    for child in tree[id].children:
        addDepth(child, tree)


if __name__ == "__main__":
    lines = sys.stdin.readlines()
    N = int(lines[0])
    del lines[0]
    tree = []
    for i in range(N):
        tree.append(Node())
    for line in lines:
        line = list(map(int, line.split()))
        tree[line[0]].id = line[0]
        tree[line[0]].children = line[2:]
    for node in tree:
        for child in node.children:
            tree[child].parent = node.id
            addDepth(child, tree)
            if tree[child].children:
                tree[child].type = "internal node"
            else:
                tree[child].type = "leaf"
    for node in tree:
        print(
            "node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format(
                node
            )
        )

import sys


class Node:
    def __init__(self):
        self.id = -1
        self.parent = -1
        self.type = "leaf"

    def printInfo(self):
        print(
            "node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format(
                self
            )
        )


def setTree(id, tree, depth):
    tree[id].depth = depth
    if not tree[id].children:
        return
    for child in tree[id].children:
        tree[child].parent = id
        setTree(child, tree, depth + 1)
    tree[id].type = "internal node"


if __name__ == "__main__":
    lines = sys.stdin.readlines()
    N = int(lines[0])
    del lines[0]
    tree = []
    for i in range(N):
        tree.append(Node())
    root = N * (N - 1) / 2
    for line in lines:
        info = list(map(int, line.split()))
        tree[info[0]].children = info[2:]
        tree[info[0]].id = info[0]
        for i in tree[info[0]].children:
            root -= i
    setTree(root, tree, 0)
    tree[root].type = "root"
    for node in tree:
        node.printInfo()

-        self.id = 0 +        self.id = -1 -        self.depth = 0 -        self.type = "root" -        self.children = [] +        self.type = "leaf" + +    def printInfo(self): +        print( +            "node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format( +                self +            ) +        ) -def addDepth(id, tree): -    tree[id].depth += 1 +def setTree(id, tree, depth): +    tree[id].depth = depth +    if not tree[id].children: +        return -        addDepth(child, tree) +        tree[child].parent = id +        setTree(child, tree, depth + 1) +    tree[id].type = "internal node" +    root = N * (N - 1) / 2 -        line = list(map(int, line.split())) -        tree[line[0]].id = line[0] -        tree[line[0]].children = line[2:] +        info = list(map(int, line.split())) +        tree[info[0]].children = info[2:] +        tree[info[0]].id = info[0] +        for i in tree[info[0]].children: +            root -= i +    setTree(root, tree, 0) +    tree[root].type = "root" -        for child in node.children: -            tree[child].parent = node.id -            addDepth(child, tree) -            if tree[child].children: -                tree[child].type = "internal node" -            else: -                tree[child].type = "leaf" -    for node in tree: -        print( -            "node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format( -                node -            ) -        ) +        node.printInfo()