import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
} Main public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
} main {
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
} int a=0 a 0 b=0 b 0 c=0 c 0 i=0 i 0 j=0 j 0 k=0 k 0 minj=0; minj 0 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String str; str while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  } true {
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  } try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    } catch(Exception e){
      str = "";
      break;
    } Exception e {
      str = "";
      break;
    } str = "" str "" break; {
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    } String line = reader.readLine(); line reader.readLine() reader.readLine reader str = line str line if (str == "-") {
        break;
      } str == "-" str "-" {
        break;
      } break; line = reader.readLine() line reader.readLine() reader.readLine reader a = Integer.parseInt(line) a Integer.parseInt(line) Integer.parseInt Integer line for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    } j = 0; j = 0 j 0 j < a j a j++ j++ j {
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    } {
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    } try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      } catch(Exception e){
        c = 0;
        break;
      } Exception e {
        c = 0;
        break;
      } c = 0 c 0 break; {
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      } String line2 = reader.readLine(); line2 reader.readLine() reader.readLine reader c = Integer.parseInt(line2) c Integer.parseInt(line2) Integer.parseInt Integer line2 String str1 = str.substring(0,c); str1 str.substring(0,c) str.substring str 0 c String str2 = str.substring(c); str2 str.substring(c) str.substring str c str = str2 + str1 str str2 + str1 str2 str1 System.out.println(str) System.out.println System.out System System.out str String args[] args public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
} public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
} Main
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
}
