Problem H: String - Shuffle

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $97$ 正确数量 $68$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL 字符串

Shuffle 

Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. 

A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. 

The deck of cards is represented by a string as follows.

abcdeefab 

The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. 

For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: 

eefababcd 

You can repeat such shuffle operations. 

Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).

The input consists of multiple datasets. Each dataset is given in the following format: 

A string which represents a deck 

The number of shuffle m 

h1 

h2 

 . 

 . 

hm 

The input ends with a single character '-' for the string.

For each dataset, print a string which represents the final state in a line.
aabc
3
1
2
1
vwxyz
2
3
4
-
aabc
xyzvw

The length of the string ≤ 200 

1 ≤ m ≤ 100 

1 ≤ hi < The length of the string 

The number of datasets ≤ 10