import java.io.*;

public class Main{ 
        public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        }
    } import java.io.*; io.* java public class Main{ 
        public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        }
    } Main public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        } main {
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        } int i i m m j=0 j 0 kazu kazu k k a a count=0; count 0 int b[]; b String kard; kard BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            } catch (IOException e){
                System.out.println(e);
            } IOException e {
                System.out.println(e);
            } System.out.println(e) System.out.println System.out System System.out e {    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } b = new int[400] b new int[400] 400 String[] kard1=new String[500]; kard1 new String[500] 500 String[][] temp=new String[20][500]; temp new String[20][500] 20 500 while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                } true {
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                } kard=reader.readLine() kard reader.readLine() reader.readLine reader b[j]=kard.length() b[j] b j kard.length() kard.length kard if(kard.equals("-")){
                        break;
                    } kard.equals("-") kard.equals kard "-" {
                        break;
                    } break; for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    } i=0; i=0 i 0 i<b[j] i b[j] b j i++ i++ i {
                        kard1[i]=String.valueOf(kard.charAt(i));
                    } {
                        kard1[i]=String.valueOf(kard.charAt(i));
                    } kard1[i]=String.valueOf(kard.charAt(i)) kard1[i] kard1 i String.valueOf(kard.charAt(i)) String.valueOf String kard.charAt(i) kard.charAt kard i String kazul=reader.readLine(); kazul reader.readLine() reader.readLine reader kazu = Integer.parseInt(kazul) kazu Integer.parseInt(kazul) Integer.parseInt Integer kazul for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    } m=0; m=0 m 0 m<kazu m kazu m++ m++ m {
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    } {
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    } String al=reader.readLine(); al reader.readLine() reader.readLine reader a = Integer.parseInt(al) a Integer.parseInt(al) Integer.parseInt Integer al k=0 k 0 for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        } i=a; i=a i a i<b[j] i b[j] b j i++ i++ i {
                            temp[count][k]=kard1[i];
                            k++;
                        } {
                            temp[count][k]=kard1[i];
                            k++;
                        } temp[count][k]=kard1[i] temp[count][k] temp[count] temp count k kard1[i] kard1 i k++ k for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        } i=0; i=0 i 0 i<a i a i++ i++ i {
                            temp[count][k]=kard1[i];
                            k++;
                        } {
                            temp[count][k]=kard1[i];
                            k++;
                        } temp[count][k]=kard1[i] temp[count][k] temp[count] temp count k kard1[i] kard1 i k++ k for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        } i=0; i=0 i 0 i<b[j] i b[j] b j i++ i++ i {
                            kard1[i]=temp[count][i];
                        } {
                            kard1[i]=temp[count][i];
                        } kard1[i]=temp[count][i] kard1[i] kard1 i temp[count][i] temp[count] temp count i j++ j count++ count i=0 i 0 while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                } count>i count i {
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                } for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    } j=0; j=0 j 0 j<b[i] j b[i] b i j++ j++ j {
                        System.out.print(temp[i][j]);
                    } {
                        System.out.print(temp[i][j]);
                    } System.out.print(temp[i][j]) System.out.print System.out System System.out temp[i][j] temp[i] temp i j System.out.printf("\n") System.out.printf System.out System System.out "\n" i++ i String[] args args public class Main{ 
        public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        }
    } public class Main{ 
        public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        }
    } Main
import java.io.*;

public class Main{ 
        public static void main(String[] args){
            int i,m,j=0,kazu,k,a,count=0;
            int b[];
            String kard;
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{    b = new int[400];
                String[] kard1=new String[500];
                String[][] temp=new String[20][500];
                while(true){
                    kard=reader.readLine();
                    b[j]=kard.length();
                    if(kard.equals("-")){
                        break;
                    }
                    for(i=0;i<b[j];i++){
                        kard1[i]=String.valueOf(kard.charAt(i));
                    }
                    String kazul=reader.readLine();
                    kazu = Integer.parseInt(kazul);
                    for(m=0;m<kazu;m++){
                        String al=reader.readLine();
                        a = Integer.parseInt(al);
                        k=0;
                        for(i=a;i<b[j];i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<a;i++){
                            temp[count][k]=kard1[i];
                            k++;
                        }
                        for(i=0;i<b[j];i++){
                            kard1[i]=temp[count][i];
                        }
                    }
                    j++;
                    count++;
                }
                i=0;
                while(count>i){
                    for(j=0;j<b[i];j++){
                        System.out.print(temp[i][j]);
                    }
                    System.out.printf("\n");
                    i++;
                }
            } catch (IOException e){
                System.out.println(e);
            }
        }
    }
