main=getLine>>=interact.f f"encode"=e f _=d e(a:b:x)=a:e x++[b] e x=x d(a:x)=a:d(reverse x) d x=x