import java.util.*;
 
public class Main {
	
    public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	}
} import java.util.*; util.* java public class Main {
	
    public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	}
} Main public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	} main {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	} Scanner scan	= new Scanner( System.in ); scan new Scanner( System.in ) while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		} true {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		} String	n		= scan.next(); n scan.next() scan.next scan if ( n.equals("-") ) {
				break;
			} n.equals("-") n.equals n "-" {
				break;
			} break; int	m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			} {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan n = n.substring( h, n.length() ) + n.substring( 0, h ) n n.substring( h, n.length() ) + n.substring( 0, h ) n.substring( h, n.length() ) n.substring n h n.length() n.length n n.substring( 0, h ) n.substring n 0 h System.out.println( n ) System.out.println System.out System System.out n scan.close() scan.close scan String args[] args public class Main {
	
    public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	}
} public class Main {
	
    public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	}
} Main
import java.util.*;
 
public class Main {
	
    public static void main( String args[] ) {
        Scanner scan	= new Scanner( System.in );

		while( true ) {
			// 文字列入力
			String	n		= scan.next();
			if ( n.equals("-") ) {
				break;
			}

			// 処理
			int	m = scan.nextInt();
			for( int i = 0; i < m; i++ ) {
				int h = scan.nextInt();
				n = n.substring( h, n.length() ) + n.substring( 0, h );

			}

			// 出力
			System.out.println( n );
		}
		
		scan.close();
	}
}