import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;

void main()
{
  foreach (s; stdin.byLine) {
  	if (s == "-") break;
  	int m = readln.chomp.to!int;
  	foreach (i; 0..m) {
  		int h = readln.chomp.to!int;
  		s = s[h..$] ~ s[0..h];
  	}
  	s.writeln();
  }
}