Please help to understand, why i am getting runtime error

this is my solution, i used merge sort in linked lists, but i am getting runtime error, can you please help me why?

class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

# output Function
def mergelist(l, r):
    if not l:
        return r
    if not r:
        return l
    if l.data < r.data:
        l.next = mergelist(l.next, r)
        return l
    else:
        r.next = mergelist(r.next, l)
        return r

def merge(L):
    if not L:
        return None
    if len(L) == 1:
        return L[0]
    else:
        mid = len(L) // 2
        l = merge(L[:mid])
        r = merge(L[mid:])
        return mergelist(l, r)
  
if __name__ == '__main__':
    t = int(input())
    L = []
    for T in range(t):
        l = list(map(int , input().split(" ")))
        A = Node(l[1])
        L.append(A)
        if len(l) > 2:
            for i in range(2, l[0]+1):
                A.next = Node(l[i])
                A = A.next
    a = merge(L)
    print(a)