LCS in Python