rewriting structure of input