$_=<>,$d=<>,chop,print"".($d<0?reverse:$_)x abs$d,$/while<>