import std.stdio, std.string, std.conv;

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