import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    } true {
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    } String s = sc.next(); s sc.next() sc.next sc if(s.equals("-")){
        break;
      } s.equals("-") s.equals s "-" {
        break;
      } break; int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      } {
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      } int x = Integer.parseInt(sc.next()); x Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String s1 = s.substring(0, x); s1 s.substring(0, x) s.substring s 0 x String s2 = s.substring(x); s2 s.substring(x) s.substring s x s = s2 + s1 s s2 + s1 s2 s1 System.out.printf("%s\n", s) System.out.printf System.out System System.out "%s\n" s String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      String s = sc.next();
      if(s.equals("-")){
        break;
      }
      int m = Integer.parseInt(sc.next());
      for(int i = 0; i < m; i++){
        int x = Integer.parseInt(sc.next());
        String s1 = s.substring(0, x);
        String s2 = s.substring(x);
        s = s2 + s1;
      }
      System.out.printf("%s\n", s);
    }
  }
}
