import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              } true {
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              } int sum=0; sum 0 String s = sc.next(); s sc.next() sc.next sc if(s.equals("-"))
                break; s.equals("-") s.equals s "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                  int h=sc.nextInt();
                  sum+=h;
                } {
                  int h=sc.nextInt();
                  sum+=h;
                } int h=sc.nextInt(); h sc.nextInt() sc.nextInt sc sum+=h sum h String[] d=s.split(""); d s.split("") s.split s "" int l=sum%d.length; l sum%d.length sum d.length d d.length for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                } int i=l; int i=l; i l i<d.length i d.length d d.length i++ i++ i {
                  System.out.printf("%s",d[i]);
                } {
                  System.out.printf("%s",d[i]);
                } System.out.printf("%s",d[i]) System.out.printf System.out System System.out "%s" d[i] d i for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                } int i=0; int i=0; i 0 i<l i l i++ i++ i {
                  System.out.printf("%s",d[i]);
                } {
                  System.out.printf("%s",d[i]);
                } System.out.printf("%s",d[i]) System.out.printf System.out System System.out "%s" d[i] d i System.out.println("") System.out.println System.out System System.out "" sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
          int sum=0;
                String s = sc.next();
                if(s.equals("-"))
                break;
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                  int h=sc.nextInt();
                  sum+=h;
                }
                String[] d=s.split("");
                int l=sum%d.length;
                for(int i=l;i<d.length;i++){
                  System.out.printf("%s",d[i]);
                }
                for(int i=0;i<l;i++){
                  System.out.printf("%s",d[i]);
                }
                System.out.println("");
              }
              sc.close();
    }
}
