main=interact$unlines.map(\a->a++reverse a).f f[]=[] f t=f(tail t)++[t]