
import java.util.*;
class Main {
    public static void main(String...args) {
       Scanner scan = new Scanner(System.in);
       String str = null;
       int total =0;
       while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       }
    
    }
}

 import java.util.*; util.* java class Main {
    public static void main(String...args) {
       Scanner scan = new Scanner(System.in);
       String str = null;
       int total =0;
       while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       }
    
    }
} Main public static void main(String...args) {
       Scanner scan = new Scanner(System.in);
       String str = null;
       int total =0;
       while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       }
    
    } main {
       Scanner scan = new Scanner(System.in);
       String str = null;
       int total =0;
       while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       }
    
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = null; str null int total =0; total 0 while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       } true {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       } str = scan.next() str scan.next() scan.next scan if(str.equals("-"))break; str.equals("-") str.equals str "-" break; int times = scan.nextInt(); times scan.nextInt() scan.nextInt scan for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           } int i = 0 ; int i = 0 ; i 0 i < times i times i++ i++ i {
               total += scan.nextInt();
           } {
               total += scan.nextInt();
           } total += scan.nextInt() total scan.nextInt() scan.nextInt scan for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } int n = 0; int n = 0; n 0 n < str.length() n str.length() str.length str n++ n++ n {
               System.out.print(str.charAt((total + n )%str.length()));
           } {
               System.out.print(str.charAt((total + n )%str.length()));
           } System.out.print(str.charAt((total + n )%str.length())) System.out.print System.out System System.out str.charAt((total + n )%str.length()) str.charAt str (total + n )%str.length() (total + n ) total n str.length() str.length str System.out.println() System.out.println System.out System System.out total = 0 total 0 String...args args

import java.util.*;
class Main {
    public static void main(String...args) {
       Scanner scan = new Scanner(System.in);
       String str = null;
       int total =0;
       while(true) {
           str = scan.next();
           if(str.equals("-"))break;
           int times = scan.nextInt();
           for(int i = 0 ; i < times; i++) {
               total += scan.nextInt();
           }
           for(int n = 0; n < str.length(); n++) {
               System.out.print(str.charAt((total + n )%str.length()));
           } 
           System.out.println();
           total = 0;
       }
    
    }
}


