while true do
	deck = STDIN.gets.chomp
	break if deck.eql?('-')
	
	shuffle_count = STDIN.gets.to_i

	0.upto(shuffle_count - 1) {
		shuffle_cards_num = STDIN.gets.to_i
		deck = deck[shuffle_cards_num..deck.size-1] + deck[0..shuffle_cards_num-1]
	}
	print deck, "\n"	
end

