import sys

readline = sys.stdin.readline

class Tree:

    def __init__(self):

        self.id = 0

        self.p = -1

        self.depth = -1

        self.type = "leaf"

        self.len_c = 0

        self.c = []

    def __str__(self):

        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"

n = int(eval(input()))

li = [Tree() for _ in range(n)]

for _ in range(n):

    id, k, *c = list(map(int, readline().split()))

    if k == 0:

        c = []

    else:

        li[id].type = "internal node"

    li[id].id = id

    li[id].c = c

    for j in c:

        li[j].p = id

root = 0

while True:

    a = li[root].p

    if a == -1:

        li[root].type = "root"

        li[root].depth = 0

        break

    root = a

dp = [(root, 0)]

while dp:

    id, d = dp.pop()

    for i in li[id].c:

        li[i].depth = d + 1

        dp.append((i, d + 1))

for i in range(n):

    print((li[i]))



import sys

readline = sys.stdin.readline

class Tree:

    __slots__ = ['id', 'p', 'depth', 'type', 'len_c', 'c']

    def __init__(self):

        self.id = 0

        self.p = -1

        self.depth = -1

        self.type = "leaf"

        self.len_c = 0

        self.c = []

    def __str__(self):

        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"

n = int(eval(input()))

li = [Tree() for _ in range(n)]

for _ in range(n):

    id, k, *c = list(map(int, readline().split()))

    if k == 0:

        c = []

    else:

        li[id].type = "internal node"

    li[id].id = id

    li[id].c = c

    for j in c:

        li[j].p = id

root = 0

while True:

    a = li[root].p

    if a == -1:

        li[root].type = "root"

        li[root].depth = 0

        break

    root = a

dp = [(root, 0)]

while dp:

    id, d = dp.pop()

    for i in li[id].c:

        li[i].depth = d + 1

        dp.append((i, d + 1))

for i in range(n):

    print((li[i]))



import sys

readline = sys.stdin.readline


class Tree:
    def __init__(self):
        self.id = 0
        self.p = -1
        self.depth = -1
        self.type = "leaf"
        self.len_c = 0
        self.c = []

    def __str__(self):
        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"


n = int(eval(input()))
li = [Tree() for _ in range(n)]
for _ in range(n):
    id, k, *c = list(map(int, readline().split()))
    if k == 0:
        c = []
    else:
        li[id].type = "internal node"
    li[id].id = id
    li[id].c = c
    for j in c:
        li[j].p = id
root = 0
while True:
    a = li[root].p
    if a == -1:
        li[root].type = "root"
        li[root].depth = 0
        break
    root = a
dp = [(root, 0)]
while dp:
    id, d = dp.pop()
    for i in li[id].c:
        li[i].depth = d + 1
        dp.append((i, d + 1))
for i in range(n):
    print((li[i]))

import sys

readline = sys.stdin.readline


class Tree:
    __slots__ = ["id", "p", "depth", "type", "len_c", "c"]

    def __init__(self):
        self.id = 0
        self.p = -1
        self.depth = -1
        self.type = "leaf"
        self.len_c = 0
        self.c = []

    def __str__(self):
        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"


n = int(eval(input()))
li = [Tree() for _ in range(n)]
for _ in range(n):
    id, k, *c = list(map(int, readline().split()))
    if k == 0:
        c = []
    else:
        li[id].type = "internal node"
    li[id].id = id
    li[id].c = c
    for j in c:
        li[j].p = id
root = 0
while True:
    a = li[root].p
    if a == -1:
        li[root].type = "root"
        li[root].depth = 0
        break
    root = a
dp = [(root, 0)]
while dp:
    id, d = dp.pop()
    for i in li[id].c:
        li[i].depth = d + 1
        dp.append((i, d + 1))
for i in range(n):
    print((li[i]))

+    __slots__ = ["id", "p", "depth", "type", "len_c", "c"] +