Buggy python submission (verdict: Runtime Error):
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, rightSibling, *children):
        self.id = num
        self.parent = parent
        self.rightSibling = rightSibling
        self.children = list(children)
        self.depth = 0
    def showInfo(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('{0}'.format(self.children))

def setNode(num, k, *children):
    if T[num]:
        T[num].children = list(children)
    else:
        node = Node(num, -1, None, *children)
        T[num] = node
    if children:
        for i, x in enumerate(children[:-1]):
            if T[x]:
                T[x].parent = num
                T[x].rightSibling = children[i + 1]
            else:
                node = Node(x, num, children[i + 1])
                T[x] = node
        lastChild = children[-1]
        if T[lastChild]:
            T[lastChild].parent = num
        else:
            node = Node(lastChild, num, None)
            T[lastChild] = node

def setDepth(u, p):
    T[u].depth = p
    if T[u].children:
        setDepth(T[u].children[0], p + 1)
    if T[u].rightSibling:
        setDepth(T[u].rightSibling, p)

def findRoot(r):
    if T[r].parent == -1:
        return r
    findRoot(T[r].parent)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

for x in sys.stdin.readlines():
    setNode(*list(map(int, x.split())))

r = findRoot(0)

setDepth(r, 0)

for x in T:
    x.showInfo()

Fixed submission:
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()

Buggy python submission (verdict: Runtime Error):
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, rightSibling, *children):
        self.id = num
        self.parent = parent
        self.rightSibling = rightSibling
        self.children = list(children)
        self.depth = 0
    def showInfo(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('{0}'.format(self.children))

def setNode(num, k, *children):
    if T[num]:
        T[num].children = list(children)
    else:
        node = Node(num, -1, None, *children)
        T[num] = node
    if children:
        for i, x in enumerate(children[:-1]):
            if T[x]:
                T[x].parent = num
                T[x].rightSibling = children[i + 1]
            else:
                node = Node(x, num, children[i + 1])
                T[x] = node
        lastChild = children[-1]
        if T[lastChild]:
            T[lastChild].parent = num
        else:
            node = Node(lastChild, num, None)
            T[lastChild] = node

def setDepth(u, p):
    T[u].depth = p
    if T[u].children:
        setDepth(T[u].children[0], p + 1)
    if T[u].rightSibling != None:
        setDepth(T[u].rightSibling, p)

def findRoot(r):
    if T[r].parent == -1:
        return r
    return findRoot(T[r].parent)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

for x in sys.stdin.readlines():
    setNode(*list(map(int, x.split())))

r = findRoot(0)

setDepth(r, 0)

for x in T:
    x.showInfo()

Fixed submission:
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()

Buggy python submission (verdict: Runtime Error):
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, rightSibling, *children):
        self.id = num
        self.parent = parent
        self.rightSibling = rightSibling
        self.children = list(children)
        self.depth = 0
    def showInfo(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('{0}'.format(self.children))

def setNode(num, k, *children):
    if T[num]:
        T[num].children = list(children)
    else:
        node = Node(num, -1, None, *children)
        T[num] = node
    if children:
        for i, x in enumerate(children[:-1]):
            if T[x]:
                T[x].parent = num
                T[x].rightSibling = children[i + 1]
            else:
                node = Node(x, num, children[i + 1])
                T[x] = node
        lastChild = children[-1]
        if T[lastChild]:
            T[lastChild].parent = num
        else:
            node = Node(lastChild, num, None)
            T[lastChild] = node

def setDepth(u, p):
    T[u].depth = p
    if T[u].children:
        setDepth(T[u].children[0], p + 1)
    if T[u].rightSibling != None:
        setDepth(T[u].rightSibling, p)

def findRoot(r):
    if T[r].parent == -1:
        return r
    return findRoot(T[r].parent)


import sys

sys.setrecursionlimit(100000)

n = int(sys.stdin.readline())

T = [None for i in range(n)]

for x in sys.stdin.readlines():
    setNode(*list(map(int, x.split())))

r = findRoot(0)

setDepth(r, 0)

for x in T:
    x.showInfo()

Fixed submission:
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()

Buggy python submission (verdict: Runtime Error):
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, rightSibling, *children):
        self.id = num
        self.parent = parent
        self.rightSibling = rightSibling
        self.children = list(children)
        self.depth = 0
    def showInfo(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('{0}'.format(self.children))

def setNode(num, k, *children):
    if T[num]:
        T[num].children = list(children)
    else:
        node = Node(num, -1, None, *children)
        T[num] = node
    if children:
        for i, x in enumerate(children[:-1]):
            if T[x]:
                T[x].parent = num
                T[x].rightSibling = children[i + 1]
            else:
                node = Node(x, num, children[i + 1])
                T[x] = node
        lastChild = children[-1]
        if T[lastChild]:
            T[lastChild].parent = num
        else:
            node = Node(lastChild, num, None)
            T[lastChild] = node

def setDepth(u, p):
    T[u].depth = p
    if T[u].children:
        setDepth(T[u].children[0], p + 1)
    if T[u].rightSibling != None:
        setDepth(T[u].rightSibling, p)

def findRoot(r):
    if T[r].parent == -1:
        return r
    return findRoot(T[r].parent)


import sys

sys.setrecursionlimit(1000000)

n = int(sys.stdin.readline())

T = [None for i in range(n)]

for x in sys.stdin.readlines():
    setNode(*list(map(int, x.split())))

r = findRoot(0)

setDepth(r, 0)

for x in T:
    x.showInfo()

Fixed submission:
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()