Buggy python submission (verdict: Runtime Error):
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L(u))
def i(u):
    if u+1:i(R(u));s(u);p(L(u))
def o(u):
    if u+1:o(R(u));o(L(u));s(u)
        
n = int(inpout())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c
root = (set(range(n))-set(R)-set(L)).pop()
print(f'Preorder{p(r)}')
print(f'Inorder{i(r)}')
print(f'Postorder{o(r)}')


Fixed submission:
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L[u])
def i(u):
    if u+1:i(R[u]);s(u);i(L[u])
def o(u):
    if u+1:o(R[u]);o(L[u]);s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c

root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder');p(root)
print('\nInorder');i(root)
print('\nPostorder');o(root)
print()

Buggy python submission (verdict: Runtime Error):
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L(u))
def i(u):
    if u+1:i(R(u));s(u);p(L(u))
def o(u):
    if u+1:o(R(u));o(L(u));s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c
root = (set(range(n))-set(R)-set(L)).pop()
print(f'Preorder{p(r)}')
print(f'Inorder{i(r)}')
print(f'Postorder{o(r)}')


Fixed submission:
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L[u])
def i(u):
    if u+1:i(R[u]);s(u);i(L[u])
def o(u):
    if u+1:o(R[u]);o(L[u]);s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c

root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder');p(root)
print('\nInorder');i(root)
print('\nPostorder');o(root)
print()

Buggy python submission (verdict: Runtime Error):
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L(u))
def i(u):
    if u+1:i(R(u));s(u);p(L(u))
def o(u):
    if u+1:o(R(u));o(L(u));s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c
root = (set(range(n))-set(R)-set(L)).pop()
print(f'Preorder{p(root)}')
print(f'Inorder{i(root)}')
print(f'Postorder{o(root)}')


Fixed submission:
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L[u])
def i(u):
    if u+1:i(R[u]);s(u);i(L[u])
def o(u):
    if u+1:o(R[u]);o(L[u]);s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c

root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder');p(root)
print('\nInorder');i(root)
print('\nPostorder');o(root)
print()

Buggy python submission (verdict: Runtime Error):
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(R(u+n))
def i(u):
    if u+1:i(R(u));s(u);p(L(u))
def o(u):
    if u+1:o(R(u));o(L(u));s(u)
        
n = int(input())
R, L = [0]*2*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a], R[a+n] = b,c
    L[a] = c
root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder',end = '');p(root)
print('\nInorder',end = '');i(root)
print('\nPostorder',end='');o(root)
print()


Fixed submission:
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L[u])
def i(u):
    if u+1:i(R[u]);s(u);i(L[u])
def o(u):
    if u+1:o(R[u]);o(L[u]);s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c

root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder');p(root)
print('\nInorder');i(root)
print('\nPostorder');o(root)
print()

Buggy python submission (verdict: Runtime Error):
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L(u))
def i(u):
    if u+1:i(R(u));s(u);p(L(u))
def o(u):
    if u+1:o(R(u));o(L(u));s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c
root = (set(range(n))-set(R)-set(L)).pop()
print(f'Preorder{p(root)}')
print(f'Inorder{i(root)}')
print(f'Postorder{o(root)}')


Fixed submission:
def s(x):
    print('',x,end='')
def p(u):
    if u+1:s(u);p(R[u]);p(L[u])
def i(u):
    if u+1:i(R[u]);s(u);i(L[u])
def o(u):
    if u+1:o(R[u]);o(L[u]);s(u)
        
n = int(input())
R, L = [0]*n, [0]*n
for _ in range(n):
    a, b, c = map(int, input().split())
    R[a] = b
    L[a] = c

root = (set(range(n))-set(R)-set(L)).pop()
print('Preorder');p(root)
print('\nInorder');i(root)
print('\nPostorder');o(root)
print()