s = []
count = 0

while true
    input = STDIN.gets.chomp()
    if input == "-" then
        break
    else
        m = STDIN.gets.chomp().to_i
        h = []
        for i in 0..m - 1 do
            _h = STDIN.gets.chomp().to_i
            h << _h
        end
        s[count] = { string:input, m:m, h:h}
        # p s[count]
    end
    count += 1
end

for i in 0..s.length - 1 do
    str = s[i][:string]
    for j in 0..s[i][:m] - 1 do
        # puts str
        num = s[i][:h][j]
        substr = str.slice(num .. str.length - 1)
        str = substr + str.slice(0 .. s[i][:h][j] - 1)
    end
    puts str
end