while s=gets.chop a=s[b=s.length-1] s[b]=s[0] s[0]=a puts s end