import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
}
 import java.io.*; io.* java import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
} Main public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  } main {
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int m; m int h; h String s; s String card; card String card2; card2 while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    } true {
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    } card=sc.next() card sc.next() sc.next sc if(card.startsWith("-")) break; card.startsWith("-") card.startsWith card "-" break; m=sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      } int i=0; int i=0; i 0 i<m i m i++ i++ i {
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      } {
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      } h=sc.nextInt() h sc.nextInt() sc.nextInt sc card2=card.substring(0,h) card2 card.substring(0,h) card.substring card 0 h card=card.substring(h) card card.substring(h) card.substring card h card=card+card2 card card+card2 card card2 System.out.println(card) System.out.println System.out System System.out card String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
} Main
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m;
    int h;
    String s;
    String card;
    String card2;
    while(true){
      card=sc.next();
      if(card.startsWith("-")) break;
      m=sc.nextInt();
      for(int i=0;i<m;i++){
        h=sc.nextInt();
        card2=card.substring(0,h);
        card=card.substring(h);
        card=card+card2;
      }
      System.out.println(card);
    }
  }
}

