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


int main()
{
	string s;
	int n, m;
	while (true)
	{
		cin >> s;
		if (s == "-")
			break;
		cin >> n;
		int p = 0;
		while (n > 0)
		{
			cin >> m;
			s += s.substr(p, m);
			p += m;
			n--;
		}
		cout << s.substr(p) << endl;
	}
	return 0;
}

