class Node:

    def __init__(self, num, parent, leftmostChild, rightSibling):

        self.id = num

        self.parent = parent

        self.leftmostChild = leftmostChild

        self.rightSibling = rightSibling

        self.depth = 0

        

    def show_info(self):

        print('node {0}: '.format(self.id), end = '')

        print('parent = {0}, '.format(self.parent.id), end = '')

        print('depth = {0}, '.format(self.depth), end = '')

        if self.leftmostChild and self.parent.id != -1:

            print('internal node, ', end = '')

        elif self.parent.id != -1:

            print('leaf, ', end = '')

        else:

            print('root, ', end = '')

        print('[', end = '')

        t_n = self.leftmostChild

        if t_n:

            print(t_n.id, end = '')

            t_n = t_n.rightSibling

        while t_n:

            print(', {0}'.format(t_n.id), end = '')

            t_n = t_n.rightSibling

        print(']')





class RootedTree():

    def __init__(self, n):

        self.base_node = Node(-1, None, None, None)

        self.nodes = [Node(i, self.base_node, None, None) for i in range(n)]

    

    def set_node(self, num, k, *children):

        if children:

            self.nodes[num].leftmostChild = self.nodes[children[0]]

            for i, x in enumerate(children[:-1]):

                self.nodes[x].parent = self.nodes[num]

                self.nodes[x].rightSibling = self.nodes[children[i + 1]]

            self.nodes[children[-1]].parent = self.nodes[num]



    def set_depth(self):

        for n in self.nodes:

            t_n = n

            while t_n.parent.id != -1:

                n.depth += 1

                t_n = t_n.parent



    def show_nodes_info(self):

        for n in self.nodes:

            n.show_info()







import sys



n = int(sys.stdin.readline())



T = RootedTree(n)



for x in sys.stdin.readlines():

    T.set_node(*list(map(int, x.split())))



T.set_depth()



T.show_nodes_info()

"""Rooted Trees."""



class Node:

    def __init__(self, num, parent, *children):

        self.id = num

        self.parent = parent

        self.children = list(children)

        self.depth = 0

        

    def show_info(self):

        print('node {0}: '.format(self.id), end = '')

        print('parent = {0}, '.format(self.parent), end = '')

        print('depth = {0}, '.format(self.depth), end = '')

        if self.children and self.parent != -1:

            print('internal node, ', end = '')

        elif self.parent != -1:

            print('leaf, ', end = '')

        else:

            print('root, ', end = '')

        print(self.children)





class RootedTree():

    def __init__(self, n):

        self.nodes = [Node(i, -1) for i in range(n)]

    

    def set_node(self, i_p):

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

        num = i_p[0]

        children = i_p[2:]

        if children:

            self.nodes[num].children = children

            for n in children:

                self.nodes[n].parent = num



    def set_depth(self):

        for n in self.nodes:

            t_n = n

            while t_n.parent != -1:

                n.depth += 1

                t_n = self.nodes[t_n.parent]



    def show_nodes_info(self):

        for n in self.nodes:

            n.show_info()







import sys



n = int(sys.stdin.readline())



T = RootedTree(n)



for x in sys.stdin.readlines():

    T.set_node(x)



T.set_depth()



T.show_nodes_info()

class Node:
    def __init__(self, num, parent, leftmostChild, rightSibling):
        self.id = num
        self.parent = parent
        self.leftmostChild = leftmostChild
        self.rightSibling = rightSibling
        self.depth = 0

    def show_info(self):
        print("node {0}: ".format(self.id), end="")
        print("parent = {0}, ".format(self.parent.id), end="")
        print("depth = {0}, ".format(self.depth), end="")
        if self.leftmostChild and self.parent.id != -1:
            print("internal node, ", end="")
        elif self.parent.id != -1:
            print("leaf, ", end="")
        else:
            print("root, ", end="")
        print("[", end="")
        t_n = self.leftmostChild
        if t_n:
            print(t_n.id, end="")
            t_n = t_n.rightSibling
        while t_n:
            print(", {0}".format(t_n.id), end="")
            t_n = t_n.rightSibling
        print("]")


class RootedTree:
    def __init__(self, n):
        self.base_node = Node(-1, None, None, None)
        self.nodes = [Node(i, self.base_node, None, None) for i in range(n)]

    def set_node(self, num, k, *children):
        if children:
            self.nodes[num].leftmostChild = self.nodes[children[0]]
            for i, x in enumerate(children[:-1]):
                self.nodes[x].parent = self.nodes[num]
                self.nodes[x].rightSibling = self.nodes[children[i + 1]]
            self.nodes[children[-1]].parent = self.nodes[num]

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent.id != -1:
                n.depth += 1
                t_n = t_n.parent

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()


import sys

n = int(sys.stdin.readline())
T = RootedTree(n)
for x in sys.stdin.readlines():
    T.set_node(*list(map(int, x.split())))
T.set_depth()
T.show_nodes_info()

"""Rooted Trees."""


class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0

    def show_info(self):
        print("node {0}: ".format(self.id), end="")
        print("parent = {0}, ".format(self.parent), end="")
        print("depth = {0}, ".format(self.depth), end="")
        if self.children and self.parent != -1:
            print("internal node, ", end="")
        elif self.parent != -1:
            print("leaf, ", end="")
        else:
            print("root, ", end="")
        print(self.children)


class RootedTree:
    def __init__(self, n):
        self.nodes = [Node(i, -1) for i in range(n)]

    def set_node(self, i_p):
        i_p = list(map(int, i_p.split()))
        num = i_p[0]
        children = i_p[2:]
        if children:
            self.nodes[num].children = children
            for n in children:
                self.nodes[n].parent = num

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent != -1:
                n.depth += 1
                t_n = self.nodes[t_n.parent]

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()


import sys

n = int(sys.stdin.readline())
T = RootedTree(n)
for x in sys.stdin.readlines():
    T.set_node(x)
T.set_depth()
T.show_nodes_info()

+"""Rooted Trees.""" + + -    def __init__(self, num, parent, leftmostChild, rightSibling): +    def __init__(self, num, parent, *children): -        self.leftmostChild = leftmostChild -        self.rightSibling = rightSibling +        self.children = list(children) -        print("parent = {0}, ".format(self.parent.id), end="") +        print("parent = {0}, ".format(self.parent), end="") -        if self.leftmostChild and self.parent.id != -1: +        if self.children and self.parent != -1: -        elif self.parent.id != -1: +        elif self.parent != -1: -        print("[", end="") -        t_n = self.leftmostChild -        if t_n: -            print(t_n.id, end="") -            t_n = t_n.rightSibling -        while t_n: -            print(", {0}".format(t_n.id), end="") -            t_n = t_n.rightSibling -        print("]") +        print(self.children) -        self.base_node = Node(-1, None, None, None) -        self.nodes = [Node(i, self.base_node, None, None) for i in range(n)] +        self.nodes = [Node(i, -1) for i in range(n)] -    def set_node(self, num, k, *children): +    def set_node(self, i_p): +        i_p = list(map(int, i_p.split())) +        num = i_p[0] +        children = i_p[2:] -            self.nodes[num].leftmostChild = self.nodes[children[0]] -            for i, x in enumerate(children[:-1]): -                self.nodes[x].parent = self.nodes[num] -                self.nodes[x].rightSibling = self.nodes[children[i + 1]] -            self.nodes[children[-1]].parent = self.nodes[num] +            self.nodes[num].children = children +            for n in children: +                self.nodes[n].parent = num -            while t_n.parent.id != -1: +            while t_n.parent != -1: -                t_n = t_n.parent +                t_n = self.nodes[t_n.parent] -    T.set_node(*list(map(int, x.split()))) +    T.set_node(x)