import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);

    while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java import java.lang.*; lang.* java class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);

    while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    }
  }
} Main public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);

    while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    }
  } main {
    Scanner scan=new Scanner(System.in);

    while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    }
  } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    } true {
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    } StringBuilder sb=new StringBuilder(scan.next()); sb new StringBuilder(scan.next()) if(sb.toString().equals("-"))break; sb.toString().equals("-") sb.toString().equals sb.toString() sb.toString sb "-" break; int m=Integer.parseInt(scan.next()); m Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      } int i=0; int i=0; i 0 i<m i m i++ i++ i {
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      } {
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      } int h=Integer.parseInt(scan.next()); h Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan String buf=sb.substring(0,h); buf sb.substring(0,h) sb.substring sb 0 h sb.delete(0,h) sb.delete sb 0 h sb.append(buf) sb.append sb buf System.out.println(sb) System.out.println System.out System System.out sb String[] args args
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);

    while(true){
      StringBuilder sb=new StringBuilder(scan.next());
      if(sb.toString().equals("-"))break;
      int m=Integer.parseInt(scan.next());
      for(int i=0;i<m;i++){
        int h=Integer.parseInt(scan.next());
        String buf=sb.substring(0,h);
        sb.delete(0,h);
        sb.append(buf);
      }
      System.out.println(sb);
    }
  }
}
