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

public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.io.*; io.* java public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 } main {
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  } true {
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  } String S=sc.next(); S sc.next() sc.next sc if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     } S.equals("-") S.equals S "-" {
        break;
      } break; {
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     } char[] c = S.toCharArray(); c S.toCharArray() S.toCharArray S int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      } int i=0; int i=0; i 0 i<m i m i++ i++ i {
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      } {
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      } int h= sc.nextInt(); h sc.nextInt() sc.nextInt sc for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      } int j=0; int j=0; j 0 j<h j h j++ j++ j {
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      } {
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      } char[] temp = new char[h]; temp new char[h] h temp[j] = c[0] temp[j] temp j c[0] c 0 for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          } int k=1; int k=1; k 1 k<c.length k c.length c c.length k++ k++ k {
            c[k-1]=c[k];
            //System.out.print(c[k]);
          } {
            c[k-1]=c[k];
            //System.out.print(c[k]);
          } c[k-1]=c[k] c[k-1] c k-1 k 1 c[k] c k c[c.length-1]=temp[j] c[c.length-1] c c.length-1 c.length c c.length 1 temp[j] temp j for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      } int l=0; int l=0; l 0 l<c.length l c.length c c.length l++ l++ l {
       System.out.print(c[l]);
      } {
       System.out.print(c[l]);
      } System.out.print(c[l]) System.out.print System.out System System.out c[l] c l System.out.println() System.out.println System.out System System.out String[] args args public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
} public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;

public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
}
