import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  }
} Main public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  } main {

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  } Scanner in = new Scanner(System.in); in new Scanner(System.in) String input = in.nextLine(); input in.nextLine() in.nextLine in while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    } !input.equals("-") input.equals("-") input.equals input "-" {
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    } String tmp = in.nextLine(); tmp in.nextLine() in.nextLine in int h_cnt = Integer.parseInt(tmp); h_cnt Integer.parseInt(tmp) Integer.parseInt Integer tmp StringBuffer sb = new StringBuffer(input); sb new StringBuffer(input) for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        } int i=0; int i=0; i 0 i<h_cnt i h_cnt i++ i++ i {
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        } {
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        } tmp = in.nextLine() tmp in.nextLine() in.nextLine in int h_pos = Integer.parseInt(tmp); h_pos Integer.parseInt(tmp) Integer.parseInt Integer tmp String del_str = sb.substring(0,h_pos); del_str sb.substring(0,h_pos) sb.substring sb 0 h_pos sb = sb.delete(0,h_pos) sb sb.delete(0,h_pos) sb.delete sb 0 h_pos sb.append(del_str) sb.append sb del_str System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb input = in.nextLine() input in.nextLine() in.nextLine in String[] arg arg
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  }
}