import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String line, str;
    int m, h;
    while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    }
    System.out.print(sb);
  }
} import java.io.*; io.* java class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String line, str;
    int m, h;
    while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    }
    System.out.print(sb);
  }
} Main public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String line, str;
    int m, h;
    while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    }
    System.out.print(sb);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String line, str;
    int m, h;
    while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    }
    System.out.print(sb);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String line line str; str int m m h; h while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    } true {
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    } line = br.readLine() line br.readLine() br.readLine br if (line.equals("-")) {break;} line.equals("-") line.equals line "-" {break;} break; m = Integer.parseInt(br.readLine()) m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      } {
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      } h = Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = line.substring(0,h) str line.substring(0,h) line.substring line 0 h line = line.substring(h, line.length()) + str line line.substring(h, line.length()) + str line.substring(h, line.length()) line.substring line h line.length() line.length line str sb.append(line).append("\n") sb.append(line).append sb.append(line) sb.append sb line "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String line, str;
    int m, h;
    while(true){
      line = br.readLine();
      if (line.equals("-")) {break;}
      m = Integer.parseInt(br.readLine());
      for (int i = 0; i < m; i++){
        h = Integer.parseInt(br.readLine());
        str = line.substring(0,h);
        line = line.substring(h, line.length()) + str;
      }
    sb.append(line).append("\n");
    }
    System.out.print(sb);
  }
}