def shuffle(str, h)
    return str[h..str.size-1]+str[0..h-1]
end
loop do
    s=gets.chomp
    if s=="-"
        break
    end
    m=gets.to_i
    hs=[]
    m.times do
        s = shuffle(s, gets.to_i)
    end
    puts s
end
