def standardise(P, Q): n, m = len(P), len(Q) if n < m: P = P + [0] * (m - n) else: Q = Q + [0] * (n - m) return P, Q