import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
    public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {
    public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} Main public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    } exec {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        } true {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        } String line = br.readLine(); line br.readLine() br.readLine br if ("-".equals(line))
            	break; "-".equals(line) "-".equals "-" line break; int len = line.length(); len line.length() line.length line int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int h = 0; h 0 for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            	h += Integer.parseInt(br.readLine());
            } {
            	h += Integer.parseInt(br.readLine());
            } h += Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br h %= len h len if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            } h == 0 h 0 out.println(line) out.println out line {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            } out.print(line.substring(h, len)) out.print out line.substring(h, len) line.substring line h len out.println(line.substring(0, h)) out.println out line.substring(0, h) line.substring line 0 h out.flush() out.flush out public static void main(String[] args) throws IOException {
        new Main().exec();
    } main {
        new Main().exec();
    } new Main().exec() new Main().exec new Main() String[] args args public class Main {
    public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} public class Main {
    public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
    public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            String line = br.readLine();
            if ("-".equals(line))
            	break;
            int len = line.length();
            int m = Integer.parseInt(br.readLine());
            int h = 0;
            for (int i=0; i<m; i++) {
            	h += Integer.parseInt(br.readLine());
            }
            h %= len;
            if(h == 0)
            	out.println(line);
            else {
            	out.print(line.substring(h, len));
            	out.println(line.substring(0, h));
            }
            out.flush();
        }
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}