Buggy python submission (verdict: Runtime Error):
class Node:
    parent = NIL
    left = NIL
    right = NIL
    label = ""


def show_info(u):
    global T, D
    if T[i].parent == NIL:
        T[u].label = "root"
    elif T[i].left == NIL:
        T[u].label = "leaf"
    else:
        T[u].label = "internal node"
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(u, T[u].parent, D[u], T[u].label, getChildren(u)))


def getChildren(u):
    global T
    c = T[u].left
    R =[]
    while c != NIL:
        R.append(c)
        c = T[c].right
    return R


def setDepth(u,p):
    global T, D
    D[u] = p
    if T[u].right != NIL:
        setDepth(T[u].right, p)
    if T[u].left != NIL:
        setDepth(T[u].left, p + 1)


if __name__ == "__main__":
    n = int(input())
    T = [None] * n
    D = [None] * n
    for i in range(n):
        T[i] = Node()
    for i in range(n):
        tmp = list(map(int, input().split()))
        id = tmp.pop(0)
        k = tmp.pop(0)
        C = tmp
        if k != 0:
            T[id].left = C[0]
            for j in range(len(C)):
                T[C[j]].parent = id
            for j in range(len(C) - 1):
                T[C[j]].right = C[j + 1]
    # ??±????¨????
    setDepth(0, 0)
    for i in range(n):
        show_info(i)

Fixed submission:
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')

Buggy python submission (verdict: Runtime Error):
class Node:
    parent = NIL
    left = NIL
    right = NIL
    label = ""


def show_info(u):
    global T, D
    if T[i].parent == NIL:
        T[u].label = "root"
    elif T[i].left == NIL:
        T[u].label = "leaf"
    else:
        T[u].label = "internal node"
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(u, T[u].parent, D[u], T[u].label, getChildren(u)))


def getChildren(u):
    global T
    c = T[u].left
    R =[]
    while c != NIL:
        R.append(c)
        c = T[c].right
    return R


def setDepth(u,p):
    global T, D
    D[u] = p
    if T[u].right != NIL:
        setDepth(T[u].right, p)
    if T[u].left != NIL:
        setDepth(T[u].left, p + 1)


if __name__ == "__main__":
    n = int(input())
    T = [None] * n
    D = [None] * n
    for i in range(n):
        T[i] = Node()
    for i in range(n):
        tmp = list(map(int, input().split()))
        id = tmp.pop(0)
        k = tmp.pop(0)
        C = tmp
        if k != 0:
            T[id].left = C[0]
            for j in range(len(C)):
                T[C[j]].parent = id
            for j in range(len(C) - 1):
                T[C[j]].right = C[j + 1]
    # ??±????¨????
    setDepth(0, 0)
    for i in range(n):
        show_info(i)

Fixed submission:
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')

Buggy python submission (verdict: Runtime Error):
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL
    label = ""


def show_info(u):
    global T, D
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(u, T[u].parent, D[u], T[u].label, getChildren(u)))


def setLabel(n):
    for i in range(n):
        if T[i].parent == NIL:
            T[i].label = "root"
        elif T[i].left == NIL:
            T[i].label = "leaf"
        else:
            T[i].label = "internal node"


def getChildren(u):
    global T
    c = T[u].left
    R =[]
    while c != NIL:
        R.append(c)
        c = T[c].right
    return R


def setDepth(u,p):
    global T, D
    D[u] = p
    if T[u].right != NIL:
        setDepth(T[u].right, p)
    if T[u].left != NIL:
        setDepth(T[u].left, p + 1)


if __name__ == "__main__":
    n = int(input())
    T = [None] * n
    D = [0] * n
    for i in range(n):
        T[i] = Node()
    for i in range(n):
        tmp = list(map(int, input().split()))
        id = tmp.pop(0)
        k = tmp.pop(0)
        C = tmp
        if k != 0:
            T[id].left = C[0]
            for j in range(len(C)):
                T[C[j]].parent = id
            for j in range(len(C) - 1):
                T[C[j]].right = C[j + 1]
    setLabel(n)
    for i in range(n):
        if T[i].label == "root":
            root = i
    # ??±????¨????
    setDepth(root, 0)
    for i in range(n):
        show_info(i)

Fixed submission:
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')

Buggy python submission (verdict: Runtime Error):
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL
    label = ""


def setDepth(u,d):
    D[u] = d
    if T[u].left != NIL:
        setDepth(T[u].left,d + 1)
    if T[u].right != NIL:
        setDepth(T[u].right, d)


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
D = [0] * n
root_num = NIL

# ?????????????????¨??????
for i in range(n):
    T[i] = Node()
for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    C = tmp
    if k != 0:
        for c in C:
            T[c].parent = id
        T[id].left = C[0]
        for j in range(len(C) - 1):
            T[C[j]].right = C[j + 1]


# ??????????????°&??±????¨????
for i in range(n):
    if T[i].parent == NIL:
        root_num = i
        T[i].label = "root"
    elif T[i].left == NIL:
        T[i].label = "leaf"
    else:
        T[i].label = "internal node"
setDepth(root_num, 0)

for i in range(n):
    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, T[i].parent, D[i], T[i].label, getChildren(i)))

Fixed submission:
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')