11252 - String Right Shift   

Description

Given a string S, you are going to shift part of it.
Specifically, a shift on a string is to move all the characters right but the rightmost characters would be move to the leftmost.
For example, a shift on "abcd" would result in "dabc".
This problem ask you implement a function shift(char *start, char *end) that shift a substring of S starting from start to end.

 

Input

The first line is a string S. (length of S<=20)
The second is a integer n. (n<=10)
The next n lines, each contains two integers l and r.(l,r<=n)
This means that a shift on S[l]S[l+1]...S[r].
If the length of substring is one(l=r), then you should keep the string unchanged.
All these shift must be done in order.

 

Output

The result string after all n shift operations.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11252.cpp

Partial Judge Header

11252.h

Tags




Discuss