#include <iostream>
#include <string>
using namespace std;

int main() {
	string w;	
	register int i;
	int c, s;
	while (cin >> w) {
		if (w == "-") break;
		cin >> c;
		for (i = 0; c-- ;) {
			cin >> s;
			i += s;
		}
		i %= w.length();
		cout << w.substr(i) << w.substr(0, i) << endl;
	}
	return 0;
}