import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
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){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
}
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
} main {
        Scanner sc = new Scanner(System.in);
while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
} true {
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
} String str = sc.next(); str sc.next() sc.next sc if (str.equals("-"))break; str.equals("-") str.equals str "-" break; int leng = str.length(); leng str.length() str.length str int shuffle = sc.nextInt(); shuffle sc.nextInt() sc.nextInt sc for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
} int i=0; int i=0; i 0 i<shuffle i shuffle i++ i++ i {
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
} {
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc str = str.substring(n, leng) + str.substring(0, n) str str.substring(n, leng) + str.substring(0, n) str.substring(n, leng) str.substring str n leng str.substring(0, n) str.substring str 0 n System.out.println(str) System.out.println System.out System System.out str 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){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
}
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
}
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
while (true){
String str = sc.next();
if (str.equals("-"))break;
int leng = str.length();
int shuffle = sc.nextInt();
for(int i=0;i<shuffle;i++){
int n = sc.nextInt();
str = str.substring(n, leng) + str.substring(0, n);
}
System.out.println(str);
}
sc.close();
}
}
