import std.algorithm, std.array, std.container, std.range;
import std.string, std.uni, std.regex;
import std.stdio, std.conv, std.typecons;

void main()
{
  for (;;) {
    auto s = readln.chomp;
    if (s == "-") break;

    auto m = readln.chomp.to!size_t;
    auto hi = iota(m).map!(_ => readln.chomp.to!int);

    foreach (h; hi)
      s = s[h..$] ~ s[0..h];

    writeln(s);
  }
}