import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  }
} Main public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  } main {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    } {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String line; line StringBuilder cards = new StringBuilder(); cards new StringBuilder() int sTimes = 0; sTimes 0 int cuts = 0; cuts 0 while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      } true {

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      } if( (line = br.readLine()).equals("-") ) break; (line = br.readLine()).equals("-") (line = br.readLine()).equals (line = br.readLine()) line br.readLine() br.readLine br "-" break; cards.append(line) cards.append cards line sTimes = Integer.parseInt(br.readLine()) sTimes Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        } int i = 0; int i = 0; i 0 i < sTimes i sTimes i++ i++ i {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        } {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        } cuts = Integer.parseInt(br.readLine()) cuts Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br cards.append(cards.substring(0, cuts)) cards.append cards cards.substring(0, cuts) cards.substring cards 0 cuts cards.delete(0,cuts) cards.delete cards 0 cuts System.out.println(cards) System.out.println System.out System System.out cards cards.setLength(0) cards.setLength cards 0 String[] args args public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  }
} public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      StringBuilder cards = new StringBuilder();
      int sTimes = 0;
      int cuts = 0;

      while(true){

        if( (line = br.readLine()).equals("-") ) break;

        cards.append(line);
        sTimes = Integer.parseInt(br.readLine());

        for ( int i = 0; i < sTimes; i++ ) {
          cuts = Integer.parseInt(br.readLine());
          cards.append(cards.substring(0, cuts));
          cards.delete(0,cuts);
        }

        System.out.println(cards);

        cards.setLength(0);
      }
    }
  }
}
