#!/usr/bin/env ruby

if __FILE__ == $0 then
	loop do
		card = gets.chomp
		if card == '-' then
			break
		end

		gets.chomp.to_i.times do
			h = gets.chomp.to_i
            card = card[h..-1]+card[0,h]
		end
		puts card
	end
end
