import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str; str int h h m; m while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    } true {
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    } str = sc.next() str sc.next() sc.next sc if(str.equals("-")) break; str.equals("-") str.equals str "-" break; m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        } ; m>0 m 0 m-- m-- m {
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        } {
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        } h = sc.nextInt() h sc.nextInt() sc.nextInt sc String a a b; b a = str.substring(0,h) a str.substring(0,h) str.substring str 0 h b = str.substring(h) b str.substring(h) str.substring str h str = b + a str b + a b a System.out.println(str) System.out.println System.out System System.out str sc.close() sc.close sc String[] args args public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  }
} public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str;
    int h,m;
    while(true){
      str = sc.next();
      if(str.equals("-")) break;
      m = sc.nextInt();
      for(;m>0;m--){
           h = sc.nextInt();
           String a,b;
           a = str.substring(0,h);
           b = str.substring(h);
           str = b + a;
        }
      System.out.println(str);
    }
    sc.close();
  }
}
