Linear systems of equations with substitution