Longest common subsequence solution reconstruction during DP is wrong
Programming questions are off-topic here.
Anyway your matrices table and solution are not properly initialized as they contain references to the same objects. Try:
    table = [[0]*(m+1) for j in range(n+1)]
    solution = [ [&quot;&quot; for i in range(m+1)] for j in range(n+1) ]

Moreover, the returned string should be solution[n][m] and not solution[n-1][m-1].