infix-to-prefix conversion with modification