Buggy python submission (verdict: Runtime Error):
n = int(input())


class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right


dali = [0] * n


def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[i] = BiTree(node, left, right)


def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
    
            return dali[i].parent
    dali[i].parent = -1
    
    return dali[i].parent


def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1

    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1

    return max(h1, h2)


def getDegree(i):
    if dali[i].right == -1:
        dali[i].deg = 0
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"

def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]


for j in range(n):
    inputdata(j)

for j in range(n):
    getParent(j)

for j in range(n):
    getDepth(j)

h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(j)
    print(h1,h2,j)
    h1 = 0
    h2 = 0

for j in range(n):
    getDegree(j)
for j in range(n):
    getType(j)
for j in range(n):
    getSibling(j)
for j in range(n):
    print("node %d: parent = %d,sibling = %d, degree = %d, depth = %d, height = %d, %s" % (
        dali[j].node, dali[j].parent,dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))



Fixed submission:
n = int(input())
class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
dali = [0] * n
def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[node] = BiTree(node, left, right)
def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
            return dali[i].parent
    dali[i].parent = -1

    return dali[i].parent
def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1
    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1 
    return max(h1, h2)
def getDegree(i):
    if dali[i].right == -1 and dali[i].left == -1:
        dali[i].deg = 0
    elif dali[i].right == -1 :
        dali[i].deg = 1
    elif dali[i].left == -1:
        dali[i].deg = 1
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"
def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]
for j in range(n):
    inputdata(j)
for j in range(n):
    getParent(dali[j].node)
for j in range(n):
    getDepth(dali[j].node)
h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(dali[j].node)
    h1 = 0
    h2 = 0
for j in range(n):
    getDegree(dali[j].node)
for j in range(n):
    getType(dali[j].node)
for j in range(n):
    getSibling(dali[j].node)
for j in range((dali[j].node)+1):
    print("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % (dali[j].node, dali[j].parent, dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))

Buggy python submission (verdict: Runtime Error):
n = int(input())


class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right


dali = [0] * n


def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[i] = BiTree(node, left, right)


def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
    
            return dali[i].parent
    dali[i].parent = -1
    
    return dali[i].parent


def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1

    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1

    return max(h1, h2)


def getDegree(i):
    if dali[i].right == -1:
        dali[i].deg = 0
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"

def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]


for j in range(n):
    inputdata(j)

for j in range(n):
    getParent(j)

for j in range(n):
    getDepth(j)

h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(j)
    print(h1,h2,j)
    h1 = 0
    h2 = 0

for j in range(n):
    getDegree(j)
for j in range(n):
    getType(j)
for j in range(n):
    getSibling(j)
for j in range(n):
    print("node %d: parent = %d,sibling = %d, degree = %d, depth = %d, height = %d, %s" % (
        dali[j].node, dali[j].parent,dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))



Fixed submission:
n = int(input())
class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
dali = [0] * n
def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[node] = BiTree(node, left, right)
def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
            return dali[i].parent
    dali[i].parent = -1

    return dali[i].parent
def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1
    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1 
    return max(h1, h2)
def getDegree(i):
    if dali[i].right == -1 and dali[i].left == -1:
        dali[i].deg = 0
    elif dali[i].right == -1 :
        dali[i].deg = 1
    elif dali[i].left == -1:
        dali[i].deg = 1
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"
def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]
for j in range(n):
    inputdata(j)
for j in range(n):
    getParent(dali[j].node)
for j in range(n):
    getDepth(dali[j].node)
h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(dali[j].node)
    h1 = 0
    h2 = 0
for j in range(n):
    getDegree(dali[j].node)
for j in range(n):
    getType(dali[j].node)
for j in range(n):
    getSibling(dali[j].node)
for j in range((dali[j].node)+1):
    print("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % (dali[j].node, dali[j].parent, dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))

Buggy python submission (verdict: Runtime Error):
n = int(input())
class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
dali = [0] * n
def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[node] = BiTree(node, left, right)
def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
            return dali[i].parent
    dali[i].parent = -1

    return dali[i].parent
def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1
    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1 
    return max(h1, h2)
def getDegree(i):
    if dali[i].right == -1 and dali[i].left == -1:
        dali[i].deg = 0
    elif. (dali[i].right) * dali[i].left == -1:
        dali[i].deg = 1
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"
def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]
for j in range(n):
    inputdata(j)
for j in range(n):
    getParent(dali[j].node)
for j in range(n):
    getDepth(dali[j].node)
h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(dali[j].node)
    h1 = 0
    h2 = 0
for j in range(n):
    getDegree(dali[j].node)
for j in range(n):
    getType(dali[j].node)
for j in range(n):
    getSibling(dali[j].node)
for j in range((dali[j].node)+1):
    print("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % (dali[j].node, dali[j].parent, dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))



Fixed submission:
n = int(input())
class BiTree():
    def __init__(self, node, left, right):
        self.node = node
        self.left = left
        self.right = right
dali = [0] * n
def inputdata(i):
    node, left, right = list(map(int, input().split()))
    dali[node] = BiTree(node, left, right)
def getParent(i):
    for k in range(n):
        if(dali[k].right == dali[i].node) or (dali[k].left == dali[i].node):
            dali[i].parent = dali[k].node
            return dali[i].parent
    dali[i].parent = -1

    return dali[i].parent
def getDepth(i):
    h = 0
    tmp = dali[i].parent
    while True:
        if tmp == -1:
            dali[i].depth = h
            break
        else:
            tmp = getParent(tmp)
            h += 1


def getHeight(i):  # i == daliの要素番号
    h1 = 0
    h2 = 0
    if dali[i].right != -1:
        h1 = getHeight(dali[i].right) + 1
    if dali[i].left != -1:
        h2 = getHeight(dali[i].left) + 1 
    return max(h1, h2)
def getDegree(i):
    if dali[i].right == -1 and dali[i].left == -1:
        dali[i].deg = 0
    elif dali[i].right == -1 :
        dali[i].deg = 1
    elif dali[i].left == -1:
        dali[i].deg = 1
    else:
        dali[i].deg = 2


def getType(i):
    if dali[i].parent == -1:
        dali[i].type = "root"
    elif dali[i].deg == 0:
        dali[i].type = "leaf"
    else:
        dali[i].type = "internal node"
def getSibling(i):
    if dali[i].type == "root":
        dali[i].sibling = -1
        return 0
    sib = []
    sib.append((dali[dali[i].parent].right))
    sib.append(dali[dali[i].parent].left)
    if sib[0] == dali[i].node:
        dali[i].sibling = sib[1]
    else:
        dali[i].sibling = sib[0]
for j in range(n):
    inputdata(j)
for j in range(n):
    getParent(dali[j].node)
for j in range(n):
    getDepth(dali[j].node)
h1 = 0
h2 = 0
for j in range(n):
    dali[j].height = getHeight(dali[j].node)
    h1 = 0
    h2 = 0
for j in range(n):
    getDegree(dali[j].node)
for j in range(n):
    getType(dali[j].node)
for j in range(n):
    getSibling(dali[j].node)
for j in range((dali[j].node)+1):
    print("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" % (dali[j].node, dali[j].parent, dali[j].sibling, dali[j].deg, dali[j].depth, dali[j].height, dali[j].type))

Buggy python submission (verdict: Runtime Error):
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= -1
        self.depth = -1
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = []


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree.append(node(idx, -1, left,right))

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a

    tree[nd.left].sibling = nd.right
    tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        search(root.right,depth+1)
        search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2:
        root.height=0
        return hei
    else:
        return max(height(root.left,hei+1),height(root.right,hei+1))

for i in range(N):
    tree[i].height=height(i,0)




for a in range(N):
    tree[a].tostr()






    

Fixed submission:
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= 0
        self.depth = 0
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = [[] for x in range(N)]


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree[idx] = node(idx, -1, left,right)

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a
    if nd.left !=  -1:
        tree[nd.left].sibling = nd.right
    if nd.right !=  -1:
        tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        if root.right == -1 and root.left == -1:
            return
        if root.right != -1:
            search(root.right,depth+1)
        if root.left != -1:
            search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2 or (root.right == -1 and root.left == -1):
        root.height=0
        return hei
    else:
        if root.left == -1:
            return height(root.right,hei+1)
        elif root.right == -1:
            return height(root.left,hei+1)
        else:
            return max(height(root.left,hei+1),height(root.right,hei+1))
for i in range(N):
    tree[i].height=height(i,0)

for a in range(N):
    tree[a].tostr()

Buggy python submission (verdict: Runtime Error):
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= -1
        self.depth = -1
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = []


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree.append(node(idx, -1, left,right))

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a

    tree[nd.left].sibling = nd.right
    tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        search(root.right,depth+1)
        search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2:
        root.height=0
        return hei
    else:
        if root.left == -1:
            return height(root.right,hei+1)
        elif root.right == -1:
            return height(root.left,hei+1)
        else:
            return max(height(root.left,hei+1),height(root.right,hei+1))

for i in range(N):
    tree[i].height=height(i,0)




for a in range(N):
    tree[a].tostr()






    

Fixed submission:
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= 0
        self.depth = 0
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = [[] for x in range(N)]


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree[idx] = node(idx, -1, left,right)

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a
    if nd.left !=  -1:
        tree[nd.left].sibling = nd.right
    if nd.right !=  -1:
        tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        if root.right == -1 and root.left == -1:
            return
        if root.right != -1:
            search(root.right,depth+1)
        if root.left != -1:
            search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2 or (root.right == -1 and root.left == -1):
        root.height=0
        return hei
    else:
        if root.left == -1:
            return height(root.right,hei+1)
        elif root.right == -1:
            return height(root.left,hei+1)
        else:
            return max(height(root.left,hei+1),height(root.right,hei+1))
for i in range(N):
    tree[i].height=height(i,0)

for a in range(N):
    tree[a].tostr()

Buggy python submission (verdict: Runtime Error):
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= -1
        self.depth = -1
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = [[] for x in range(N)]


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree[idx] = node(idx, -1, left,right)

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a
    if nd.left !=  -1:
        tree[nd.left].sibling = nd.right
    if nd.right !=  -1:
        tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        search(root.right,depth+1)
        search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2:
        root.height=0
        return hei
    else:
        if root.left == -1:
            return height(root.right,hei+1)
        elif root.right == -1:
            return height(root.left,hei+1)
        else:
            return max(height(root.left,hei+1),height(root.right,hei+1))
for i in range(N):
    tree[i].height=height(i,0)

for a in range(N):
    tree[a].tostr()

Fixed submission:
N = int(input())
M = []

type = ['root','internal node','leaf']

class node:
    def __init__(self,idx,parent,left,right):
        self.idx = idx
        self.parent = parent
        self.left = left
        self.right= right
        
        self.sibling = -1
        self.degree= 0
        self.depth = 0
        self.height = 0
        self.type=-1

    def tostr(self):
        print('node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s' % (self.idx, self.parent, self.sibling, self.degree, self.depth, self.height, type[self.type])) 
tree = [[] for x in range(N)]


#'idx, parent, sibling, degree, depth, height, type'

for a in range(N):
    idx,left,right = map(int,input().strip().split(' '))
    tree[idx] = node(idx, -1, left,right)

for a in range(N):
    nd = tree[a]
    if nd.left != -1:
        tree[nd.left].parent = a
    if nd.right != -1:
        tree[nd.right].parent = a
    if nd.left !=  -1:
        tree[nd.left].sibling = nd.right
    if nd.right !=  -1:
        tree[nd.right].sibling = nd.left

    if nd.left == nd.right :
        nd.type=2
        nd.degree=0
    else:
        nd.type=1
        if nd.left == -1 or nd.right == -1:
            nd.degree = 1
        else:
            nd.degree = 2

root = ''
for a in range(N):
    if tree[a].parent == -1:
        root = a
        tree[root].type=0
    
def search(root,depth):
    root = tree[root]
    root.depth = depth
    if root.type ==  2:
        return
    else:
        if root.right == -1 and root.left == -1:
            return
        if root.right != -1:
            search(root.right,depth+1)
        if root.left != -1:
            search(root.left,depth+1)

search(root,0)

def height(root,hei):
    root = tree[root]
    if root.type==2 or (root.right == -1 and root.left == -1):
        root.height=0
        return hei
    else:
        if root.left == -1:
            return height(root.right,hei+1)
        elif root.right == -1:
            return height(root.left,hei+1)
        else:
            return max(height(root.left,hei+1),height(root.right,hei+1))
for i in range(N):
    tree[i].height=height(i,0)

for a in range(N):
    tree[a].tostr()