import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
} Main public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    } main {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String card; card int m = 0; m 0 int h = 0; h 0 int sum = 0; sum 0 String ans1 = ""; ans1 "" String ans2 = ""; ans2 "" while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         } true {
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         } card = sc.next() card sc.next() sc.next sc if(card.equals("-")) break; card.equals("-") card.equals card "-" break; m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                
                h = sc.nextInt();
                
                sum += h;
                
            } {
                
                h = sc.nextInt();
                
                sum += h;
                
            } h = sc.nextInt() h sc.nextInt() sc.nextInt sc sum += h sum h while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          } true {
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          } if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              } sum>=card.length() sum card.length() card.length card {
                  sum-=card.length();
              } sum-=card.length() sum card.length() card.length card {
                  break;
              } break; ans2 = card.substring(sum) ans2 card.substring(sum) card.substring card sum ans1 = card.substring(0,sum) ans1 card.substring(0,sum) card.substring card 0 sum System.out.println(ans2 + ans1) System.out.println System.out System System.out ans2 + ans1 ans2 ans1 sum = 0 sum 0 sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
} public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
}
