Applied associativity tric on matrix multiplication.