while true
        str = STDIN.gets.chomp
        break if str == "-"
        m = STDIN.gets.to_i
        m.times {|i|
                h = STDIN.gets.to_i
                new = ''
                (h..(str.length - 1)).each {|i| new += str[i] }
                h.times {|i| new += str[i] }
                str = new
        }
        puts str
end