The same idea also works for more complicated test cases: if you want to evaluate a sequence of matrices ((A1, A2, ..., Ak), (B1, B2, ..., Bm)), check whether it's possible to evaluate it as (A1, A2, ..., Ak, (B1, B2, ..., Bm)). Can you give more details please? I have tried a similar algorithm, wi...