Rotate
Time limit: 5000ms
Memory limit: 256mb
Description:
Suppose a string is arranged in a ring in clockwise direction. Fig.1 shows how string "abcdef" is arranged.
(a)- b (c)- d
/ \ / \
f c b e
\ / \ /
e - d a - f
Fig. 1 Fig. 2
We can rotate the string by n charactors (n >= 0 for counter-clockwise direction; n < 0 for clockwise direction). Fig. 2 shows what it looks like after rotate "abcdef" by 2 or -4 charactors. You are asked to calculate the string after the rotation.
Input:
A string s and an integer n. The length of s is less than 1,000 and |n| is less than 1000.
Output:
You should output only one line which contains the string after the rotation.
Sample input:
abcdef 2
Sample output:
cdefab
Submit