import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        } true {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        } String s = sc.next(); s sc.next() sc.next sc if(s.equals("-"))break; s.equals("-") s.equals s "-" break; char[] chars = s.toCharArray(); chars s.toCharArray() s.toCharArray s int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
               sum += sc.nextInt();
            } {
               sum += sc.nextInt();
            } sum += sc.nextInt() sum sc.nextInt() sc.nextInt sc for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            } int i = 0; int i = 0; i 0 i < chars.length i chars.length chars chars.length i++ i++ i {
                System.out.print(chars[(sum+i)%chars.length]);
            } {
                System.out.print(chars[(sum+i)%chars.length]);
            } System.out.print(chars[(sum+i)%chars.length]) System.out.print System.out System System.out chars[(sum+i)%chars.length] chars (sum+i)%chars.length (sum+i) sum i chars.length chars chars.length System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    } printary {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    } for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        } {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        } if(i>0) System.out.print(" "); i>0 i 0 System.out.print(" ") System.out.print System.out System System.out " " System.out.print(a[i]) System.out.print System.out System System.out a[i] a i System.out.println() System.out.println System.out System System.out int[] a a public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
} public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String s = sc.next();
            if(s.equals("-"))break;

            char[] chars = s.toCharArray();
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
               sum += sc.nextInt();
            }
            for (int i = 0; i < chars.length; i++) {
                System.out.print(chars[(sum+i)%chars.length]);
            }
            System.out.println();
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
}
