import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    } true {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    } String str = sc.next(); str sc.next() sc.next sc if (str.equals("-")) break; str.equals("-") str.equals str "-" break; int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      } {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      } int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc String str1 = str.substring(s); str1 str.substring(s) str.substring str s String str2 = str.substring(0, s); str2 str.substring(0, s) str.substring str 0 s str = str1 + str2 str str1 + str2 str1 str2 System.out.println(str) System.out.println System.out System System.out str String[] args args
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  }
}
