Rewriting printAlg1