#!ruby -pl s=gets.chop i=gets.to_i $_=i>0?s*i:s.reverse*-i