import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String cards;
    int count, shuffle;
    
    while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    }
  }
  public static String shuffle(String cards, int shuffle) {
    StringBuilder output = new StringBuilder();
    String first = cards.substring(0, shuffle);
    String last = cards.substring(shuffle, cards.length());
    cards = output.append(last).append(first).toString();
    return cards;
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String cards;
    int count, shuffle;
    
    while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    }
  }
  public static String shuffle(String cards, int shuffle) {
    StringBuilder output = new StringBuilder();
    String first = cards.substring(0, shuffle);
    String last = cards.substring(shuffle, cards.length());
    cards = output.append(last).append(first).toString();
    return cards;
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String cards;
    int count, shuffle;
    
    while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    }
  } main {
    Scanner in = new Scanner(System.in);
    String cards;
    int count, shuffle;
    
    while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) String cards; cards int count count shuffle; shuffle while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    } in.hasNext() in.hasNext in {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    } cards = in.next() cards in.next() in.next in if (cards.equals("-")) break; cards.equals("-") cards.equals cards "-" break; count = in.nextInt() count in.nextInt() in.nextInt in for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      } int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      } {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      } shuffle = in.nextInt() shuffle in.nextInt() in.nextInt in cards = shuffle(cards, shuffle) cards shuffle(cards, shuffle) shuffle cards shuffle System.out.println(cards) System.out.println System.out System System.out cards String[] args args public static String shuffle(String cards, int shuffle) {
    StringBuilder output = new StringBuilder();
    String first = cards.substring(0, shuffle);
    String last = cards.substring(shuffle, cards.length());
    cards = output.append(last).append(first).toString();
    return cards;
  } shuffle {
    StringBuilder output = new StringBuilder();
    String first = cards.substring(0, shuffle);
    String last = cards.substring(shuffle, cards.length());
    cards = output.append(last).append(first).toString();
    return cards;
  } StringBuilder output = new StringBuilder(); output new StringBuilder() String first = cards.substring(0, shuffle); first cards.substring(0, shuffle) cards.substring cards 0 shuffle String last = cards.substring(shuffle, cards.length()); last cards.substring(shuffle, cards.length()) cards.substring cards shuffle cards.length() cards.length cards cards = output.append(last).append(first).toString() cards output.append(last).append(first).toString() output.append(last).append(first).toString output.append(last).append(first) output.append(last).append output.append(last) output.append output last first return cards; cards String cards cards int shuffle shuffle
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String cards;
    int count, shuffle;
    
    while (in.hasNext()) {
      cards = in.next();
      if (cards.equals("-")) break;
      count = in.nextInt();
      
      for (int i = 0; i < count; i++) {
        shuffle = in.nextInt();
        cards = shuffle(cards, shuffle);
      }
      System.out.println(cards);
    }
  }
  public static String shuffle(String cards, int shuffle) {
    StringBuilder output = new StringBuilder();
    String first = cards.substring(0, shuffle);
    String last = cards.substring(shuffle, cards.length());
    cards = output.append(last).append(first).toString();
    return cards;
  }
}