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

int main(){
	string d("");
	int m;
	int h;
	int l;
	while(true) {
		cin >> d;
		if ( d == "-" ) break;
		cin >> m;
		l = d.size();
		for (int i = 0 ;i<m ;i++ ) {
			cin >> h;
			d = d.substr(h) + d.substr(0,h);
		}
		cout << d << endl;
	}
	return 0;
}