class Node:

    def __init__(self, num, leftChild, rightChild):

        self.id = num

        self.parent = -1

        self.sibling = -1

        self.degree = 0

        self.depth = 0

        self.height = 0

        self.type = 'leaf'

        self.leftChild = leftChild

        self.rightChild = rightChild

        

    def show_info(self):

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

              'sibling = {},'.format(self.sibling),

              'degree = {},'.format(self.degree),

              'depth = {},'.format(self.depth),

              'height = {},'.format(self.height),

              '{}'.format(self.type)))





def set_node(i_s):

    num, leftChild, rightChild = list(map(int, i_s.split()))

    node = Node(num, leftChild, rightChild)

    T[num] = node

    T[-1] -= (max(0, leftChild) + max(0, rightChild))





def set_attributes(n_i, parent, sibling, depth):

    node = T[n_i]

    node.parent = parent

    node.sibling = sibling

    node.depth = depth

    if node.leftChild != -1:

        node.degree += 1

        node.type = 'internal node'

        set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)

    if node.rightChild != -1:

        node.degree += 1

        node.type = 'internal node'

        set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)

    if node.leftChild != -1 and node.rightChild != -1:

        node.height = max(T[node.leftChild].height,

                          T[node.rightChild].height) + 1

    elif node.leftChild != -1:

        node.height = T[node.leftChild].height + 1

    elif node.rightChild != -1:

        node.height = T[node.rightChild].height + 1







import sys



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



T = [None] * n



T.append(int(n * (n - 1) / 2))



for x in sys.stdin.readlines():

    set_node(x)



set_attributes(T[-1], -1, -1, 0)



T[T[-1]].type = 'root'



for n in T[:-1]:

    n.show_info()
"""Binary Trees."""



class Node:

    def __init__(self, num, leftChild, rightChild):

        self.id = num

        self.parent = -1

        self.sibling = -1

        self.degree = 0

        self.depth = 0

        self.height = 0

        self.type = 'leaf'

        self.leftChild = leftChild

        self.rightChild = rightChild

        

    def show_info(self):

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

              'sibling = {},'.format(self.sibling),

              'degree = {},'.format(self.degree),

              'depth = {},'.format(self.depth),

              'height = {},'.format(self.height),

              '{}'.format(self.type)))





def set_attributes(n_i, parent, sibling, depth):

    if n_i == -1:

        return -1

    node = T[n_i]

    lc = node.leftChild

    rc = node.rightChild

    node.parent = parent

    node.sibling = sibling

    node.depth = depth

    node.degree = (node.leftChild != -1) + (node.rightChild != -1)

    if lc != -1 or rc != -1:

        node.type = 'internal node'

    node.height = max(set_attributes(lc, n_i, rc, depth + 1),

                      set_attributes(rc, n_i, lc, depth + 1)) + 1

    return node.height







import sys



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



T = [None] * n



rt_n = int(n * (n - 1) / 2)



for x in sys.stdin.readlines():

    num, leftChild, rightChild = list(map(int, x.split()))

    node = Node(num, leftChild, rightChild)

    T[num] = node

    rt_n -= (max(0, leftChild) + max(0, rightChild))



set_attributes(rt_n, -1, -1, 0)



T[rt_n].type = 'root'



for n in T:

    n.show_info()
class Node:
    def __init__(self, num, leftChild, rightChild):
        self.id = num
        self.parent = -1
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = "leaf"
        self.leftChild = leftChild
        self.rightChild = rightChild

    def show_info(self):
        print(
            (
                "node {}:".format(self.id),
                "parent = {},".format(self.parent),
                "sibling = {},".format(self.sibling),
                "degree = {},".format(self.degree),
                "depth = {},".format(self.depth),
                "height = {},".format(self.height),
                "{}".format(self.type),
            )
        )


def set_node(i_s):
    num, leftChild, rightChild = list(map(int, i_s.split()))
    node = Node(num, leftChild, rightChild)
    T[num] = node
    T[-1] -= max(0, leftChild) + max(0, rightChild)


def set_attributes(n_i, parent, sibling, depth):
    node = T[n_i]
    node.parent = parent
    node.sibling = sibling
    node.depth = depth
    if node.leftChild != -1:
        node.degree += 1
        node.type = "internal node"
        set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)
    if node.rightChild != -1:
        node.degree += 1
        node.type = "internal node"
        set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)
    if node.leftChild != -1 and node.rightChild != -1:
        node.height = max(T[node.leftChild].height, T[node.rightChild].height) + 1
    elif node.leftChild != -1:
        node.height = T[node.leftChild].height + 1
    elif node.rightChild != -1:
        node.height = T[node.rightChild].height + 1


import sys

n = int(sys.stdin.readline())
T = [None] * n
T.append(int(n * (n - 1) / 2))
for x in sys.stdin.readlines():
    set_node(x)
set_attributes(T[-1], -1, -1, 0)
T[T[-1]].type = "root"
for n in T[:-1]:
    n.show_info()

"""Binary Trees."""


class Node:
    def __init__(self, num, leftChild, rightChild):
        self.id = num
        self.parent = -1
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = "leaf"
        self.leftChild = leftChild
        self.rightChild = rightChild

    def show_info(self):
        print(
            (
                "node {}:".format(self.id),
                "parent = {},".format(self.parent),
                "sibling = {},".format(self.sibling),
                "degree = {},".format(self.degree),
                "depth = {},".format(self.depth),
                "height = {},".format(self.height),
                "{}".format(self.type),
            )
        )


def set_attributes(n_i, parent, sibling, depth):
    if n_i == -1:
        return -1
    node = T[n_i]
    lc = node.leftChild
    rc = node.rightChild
    node.parent = parent
    node.sibling = sibling
    node.depth = depth
    node.degree = (node.leftChild != -1) + (node.rightChild != -1)
    if lc != -1 or rc != -1:
        node.type = "internal node"
    node.height = (
        max(
            set_attributes(lc, n_i, rc, depth + 1),
            set_attributes(rc, n_i, lc, depth + 1),
        )
        + 1
    )
    return node.height


import sys

n = int(sys.stdin.readline())
T = [None] * n
rt_n = int(n * (n - 1) / 2)
for x in sys.stdin.readlines():
    num, leftChild, rightChild = list(map(int, x.split()))
    node = Node(num, leftChild, rightChild)
    T[num] = node
    rt_n -= max(0, leftChild) + max(0, rightChild)
set_attributes(rt_n, -1, -1, 0)
T[rt_n].type = "root"
for n in T:
    n.show_info()

+"""Binary Trees.""" + + -def set_node(i_s): -    num, leftChild, rightChild = list(map(int, i_s.split())) -    node = Node(num, leftChild, rightChild) -    T[num] = node -    T[-1] -= max(0, leftChild) + max(0, rightChild) - - +    if n_i == -1: +        return -1 +    lc = node.leftChild +    rc = node.rightChild -    if node.leftChild != -1: -        node.degree += 1 +    node.degree = (node.leftChild != -1) + (node.rightChild != -1) +    if lc != -1 or rc != -1: -        set_attributes(node.leftChild, node.id, node.rightChild, depth + 1) -    if node.rightChild != -1: -        node.degree += 1 -        node.type = "internal node" -        set_attributes(node.rightChild, node.id, node.leftChild, depth + 1) -    if node.leftChild != -1 and node.rightChild != -1: -        node.height = max(T[node.leftChild].height, T[node.rightChild].height) + 1 -    elif node.leftChild != -1: -        node.height = T[node.leftChild].height + 1 -    elif node.rightChild != -1: -        node.height = T[node.rightChild].height + 1 +    node.height = ( +        max( +            set_attributes(lc, n_i, rc, depth + 1), +            set_attributes(rc, n_i, lc, depth + 1), +        ) +        + 1 +    ) +    return node.height -T.append(int(n * (n - 1) / 2)) +rt_n = int(n * (n - 1) / 2) -    set_node(x) -set_attributes(T[-1], -1, -1, 0) -T[T[-1]].type = "root" -for n in T[:-1]: +    num, leftChild, rightChild = list(map(int, x.split())) +    node = Node(num, leftChild, rightChild) +    T[num] = node +    rt_n -= max(0, leftChild) + max(0, rightChild) +set_attributes(rt_n, -1, -1, 0) +T[rt_n].type = "root" +for n in T: