import java.io.*;
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	}
} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	} main {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	} Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); s new Scanner(new BufferedReader(new InputStreamReader(System.in))) String card = ""; card "" Integer shaffle_time = 0; shaffle_time 0 while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		} s.hasNext() s.hasNext s {
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		} String input = s.next(); input s.next() s.next s if(input.equals("-")){
				System.out.println(card);
				break;
			} input.equals("-") input.equals input "-" {
				System.out.println(card);
				break;
			} System.out.println(card) System.out.println System.out System System.out card break; try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			} catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			} NumberFormatException e {
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			} if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				} card == "" card "" {
					card = input;
				} card = input card input {
					System.out.println(card);
					card = input;
				} System.out.println(card) System.out.println System.out System System.out card card = input card input s.next() s.next s {
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			} shaffle_time = Integer.parseInt(input) shaffle_time Integer.parseInt(input) Integer.parseInt Integer input card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time) card card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time) card.substring(shaffle_time, card.length()) card.substring card shaffle_time card.length() card.length card card.substring(0, shaffle_time) card.substring card 0 shaffle_time s.close() s.close s String[] args args public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	}
} public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	}
} Main
import java.io.*;
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 
		String card = "";
		Integer shaffle_time = 0;
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("-")){
				System.out.println(card);
				break;
			}
			try{
				shaffle_time = Integer.parseInt(input);
				card = card.substring(shaffle_time, card.length()) + card.substring(0, shaffle_time);
			}
			catch(NumberFormatException e){
				if(card == ""){
					card = input;
				}
				else{
					System.out.println(card);
					card = input;
				}
				s.next();
			}
		}
		s.close();
	}
}