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

