Polynomials satisfied by two linked matrices