solve matrices (basic logic)