arr=Array.new
loop do
key=gets.chomp
if key=="-" then break end
t=gets.to_i
t.times do
    x=gets.to_i
    if x<key.length && x>0 then
    key=(key[x..key.length-1]+key[0..x-1])
    end
end
arr.push(key)
end
arr.each { |e|
    printf("%s\n",e)
}