Buggy python submission (verdict: Runtime Error):
n = int(input())
deg = [0]*n
child, parent = {}, {}
sib = [None]*n
for i in range(n):
    a = list(map(int, input().split()))
    if a[1] != -1:
        child[a[0]] = a[1:]
        sib[a[1]] = a[2]
        sib[a[2]] = a[1]
        deg[a[0]] = 2
        for j in child[a[0]]:
            parent[j] = a[0]
    else:
        child[a[0]] = []

root = (set(child)-set(parent)).pop()
depth = [None]*n
depth[root] = 0
hei = [None]*n
parent[root] = -1
sib[root] = -1

def dfs(s):
    if len(child[s]) == 0:
        hei[s] = 0
        return
    for i in child[s]:
        depth[i] = depth[s] + 1
        dfs(i)
    hei[s] = max(hei[i] for i in child[s]) + 1
    
    
dfs(root)

for i in range(n):
    node_type = 'root' if parent[i] == -1 else 'leaf' if len(child[i]) == 0 else 'internal node'
    print(f'node {i}: parent = {parent[i]}, sibling = {sib[i]}, degree = {deg[i]}, depth = {depth[i]}, height = {hei[i]}, {node_type}')       


Fixed submission:
n = int(input())
deg = [0]*n
child, parent = {}, {}
sib = [None]*n
for i in range(n):
    a = list(map(int, input().split()))
    if a[1] != -1:
        if a[2] == -1:
            child[a[0]] = [a[1]]
            sib[a[1]] = a[2]
            deg[a[0]] = 1
        else:
            child[a[0]] = a[1:]
            sib[a[1]] = a[2]
            sib[a[2]] = a[1]
            deg[a[0]] = 2
        for j in child[a[0]]:
            parent[j] = a[0]
    elif a[2] != -1:
        child[a[0]] = [a[2]]
        sib[a[2]] = a[1]
        deg[a[0]] = 1
        for j in child[a[0]]:
            parent[j] = a[0]
    else:
        child[a[0]] = []

root = (set(child)-set(parent)).pop()
depth = [None]*n
depth[root] = 0
hei = [None]*n
parent[root] = -1
sib[root] = -1

def dfs(s):
    if len(child[s]) == 0:
        hei[s] = 0
        return
    for i in child[s]:
        depth[i] = depth[s] + 1
        dfs(i)
    hei[s] = max(hei[i] for i in child[s]) + 1
    
    
dfs(root)

for i in range(n):
    node_type = 'root' if parent[i] == -1 else 'leaf' if len(child[i]) == 0 else 'internal node'
    print(f'node {i}: parent = {parent[i]}, sibling = {sib[i]}, degree = {deg[i]}, depth = {depth[i]}, height = {hei[i]}, {node_type}')

Buggy python submission (verdict: Runtime Error):
n = int(input())
deg = [0]*n
child, parent = {}, {}
sib = [None]*n
for i in range(n):
    a = list(map(int, input().split()))
    if a[1] != -1:
        if a[2] == -1:
            child[a[0]] = [a[1]]
            sib[a[1]] = a[2]
            deg[a[0]] = 1
        else:
            child[a[0]] = a[1:]
            sib[a[1]] = a[2]
            sib[a[2]] = a[1]
            deg[a[0]] = 2
        for j in child[a[0]]:
            parent[j] = a[0]
    else:
        child[a[0]] = []

root = (set(child)-set(parent)).pop()
depth = [None]*n
depth[root] = 0
hei = [None]*n
parent[root] = -1
sib[root] = -1

def dfs(s):
    if len(child[s]) == 0:
        hei[s] = 0
        return
    for i in child[s]:
        depth[i] = depth[s] + 1
        dfs(i)
    hei[s] = max(hei[i] for i in child[s]) + 1
    
    
dfs(root)

for i in range(n):
    node_type = 'root' if parent[i] == -1 else 'leaf' if len(child[i]) == 0 else 'internal node'
    print(f'node {i}: parent = {parent[i]}, sibling = {sib[i]}, degree = {deg[i]}, depth = {depth[i]}, height = {hei[i]}, {node_type}')   
    


Fixed submission:
n = int(input())
deg = [0]*n
child, parent = {}, {}
sib = [None]*n
for i in range(n):
    a = list(map(int, input().split()))
    if a[1] != -1:
        if a[2] == -1:
            child[a[0]] = [a[1]]
            sib[a[1]] = a[2]
            deg[a[0]] = 1
        else:
            child[a[0]] = a[1:]
            sib[a[1]] = a[2]
            sib[a[2]] = a[1]
            deg[a[0]] = 2
        for j in child[a[0]]:
            parent[j] = a[0]
    elif a[2] != -1:
        child[a[0]] = [a[2]]
        sib[a[2]] = a[1]
        deg[a[0]] = 1
        for j in child[a[0]]:
            parent[j] = a[0]
    else:
        child[a[0]] = []

root = (set(child)-set(parent)).pop()
depth = [None]*n
depth[root] = 0
hei = [None]*n
parent[root] = -1
sib[root] = -1

def dfs(s):
    if len(child[s]) == 0:
        hei[s] = 0
        return
    for i in child[s]:
        depth[i] = depth[s] + 1
        dfs(i)
    hei[s] = max(hei[i] for i in child[s]) + 1
    
    
dfs(root)

for i in range(n):
    node_type = 'root' if parent[i] == -1 else 'leaf' if len(child[i]) == 0 else 'internal node'
    print(f'node {i}: parent = {parent[i]}, sibling = {sib[i]}, degree = {deg[i]}, depth = {depth[i]}, height = {hei[i]}, {node_type}')