Solution to the string substitution problem.