AROPE2 - Alphabetic Rope2
The Alphabetic Rope is now available in the market. The Alphabetic Rope consists of alphabetic characters in each stripe which looks like string. You are given an Alphabetic Rope consisting of lowercase alphabetic characters only. You have to perform some operations on the rope and answers some queries on it and Time is increases by 1. Initial time is 0 and queries are of 4 types:
- 1 X Y: Cut the rope segment from X to Y and join at the front of rope.
- 2 X Y: Cut the rope segment from X to Y and join at the back of rope.
- 3 Y: Print on a new line the character at the Yth position of current rope.
- 4 X Y: Print on a new line the character on Yth position of rope configuration at Xth time.
Input
There is only one input. Input begins with single line giving Alphabetic Rope as a string S. Next line contains Q, following Q lines giving queries as mentioned above. (Index used are 0-based)
Output
For each query of type 3 and type 4, print a single character in a new line.
Constraints
1 <= |S| <= 10000. (Length of string)
1 <= Q <= 10000. (Number of Queries)
Example
Input: gautambishal 5 3 0 2 0 5 3 1 4 0 0 4 3 0 Output: g i g b
Added by: | BISHAL GAUTAM |
Date: | 2016-11-24 |
Time limit: | 0.300s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | MySelf |