import java.util.*;


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

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

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

    } main {
   
    Scanner sc = new Scanner(System.in);
    int a,b ;
    
    while (true) {
        String str = sc.next();
        if (str.equals("-")) {
      break; 
        }
        int i = 0;
        b = sc.nextInt();
        while(i!=b){
        String str1,str2;
        a = sc.nextInt();
        int ln =str.length();
        str1 = str.substring(0,a);
        str2 = str.substring(a,ln);
        str = "";
        str = str2 + str1;
        i++;
        }
        System.out.println(str);
    }

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

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

    }
} Main
import java.util.*;


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

    }
}
