You are given a string S.
Q number of operations are performed on string S.
In each of these Q operations, you are given an index
It is guaranteed that any index is updated atmost once.
We call the final string after performing Q number of operations as
After this, M number of operations are performed on string
In each of these M operations, you are given two indices a and b. For each operation, you have to reverse the substring that lies between the indices a and b (inclusive).
We call the final string after performing M operations as
Example: If string is "xyz" and
one of the Q operations is
one of the M operations is
You have to print string
Input Format:
First line consists of string S.
Next line consists of an integer denoting Q.
Following Q lines contain two integers each:
Next line consists of an integer denoting M.
Following M lines contain two integers each: a and b.
Output Format:
In first line, print string
In second line, print string
In third line, print the number of indices which have same characters at them in both strings
Input Constraints:
String S consists of lowercase English alphabets only.
All indices are 1 based.
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial