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

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} import java.util.*; util.* java import java.io.*; io.* java class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} Main public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String cards; cards int m = 0; m 0 int h = 0; h 0 try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } IOException e {
      e.printStackTrace();
    } e.printStackTrace() e.printStackTrace e {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      } !(cards = br.readLine()).equals("-") (cards = br.readLine()).equals("-") (cards = br.readLine()).equals (cards = br.readLine()) cards br.readLine() br.readLine br "-" {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      } m = Integer.parseInt(br.readLine()) m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        } {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        } h = Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br cards = cards.substring(h, cards.length()) + cards.substring(0, h) cards cards.substring(h, cards.length()) + cards.substring(0, h) cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards cards.substring(0, h) cards.substring cards 0 h System.out.println(cards) System.out.println System.out System System.out cards String args[] args
import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}