import java.util.*;enum M{M;System z;{String t;for(Scanner s=new Scanner(z.in);z==z;z.out.println(t))for(t=s.nextLine();t!=(t=t.replaceAll("\\W*(\\w+)(<.+|$)","<$1>$2</$1>")););}}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).