def shortest_of(lists):
    return min(lists, key=len)

def contains_sublist(lst, sublst):
    n = len(sublst)
return any(sublst == lst[i:i + n] for i in range(len(lst) - n + 1))

def longest_common(lists):
    if not lists:
        return ()
res = set()
base = shortest_of(lists)
length = len(base)
for i in range(length, 0, -1):
    for j in range(length - i + 1):
        candidate = ', ' + str(base[j:i + j]).strip('[]') + ','
for alist in lists:
    if not candidate in ', ' + str(alist).strip('[]') + ',':
        break
else:
    res.add(tuple([int(a) for a in candidate[2:-1].split(',')]))
if res:
    return tuple(res)
return ()
if __name__ == '__main__':
    a = [1, 0, 2, 5, 4, 3, 1]
b = [1, 2, 5, 4, 3, 0, 1]
c = [1, 3, 5, 4, 2, 0, 1]
print(longest_common([a, b, c]))
print(longest_common([b, c]))
how to intersect lists in python with respect to index