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 and a character . For each operation, you have to update character at index in string S to , that is, after this operation .
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 , then string "xyz" now becomes "ayz" as after the operation.
one of the M operations is , then "ayz" now becomes "zya" as the substring lying between indices 1 and 3 is reversed.
You have to print string , string and the number of indices which have same characters at them in both strings and .
Input Format:
First line consists of string S.
Next line consists of an integer denoting Q.
Following Q lines contain two integers each: and .
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 and .
Input Constraints:
; S denotes length of string s.
, all values are unique.
will always be a lowercase English alphabet.
String S consists of lowercase English alphabets only.
All indices are 1 based.
Performing first Q (=2) operations: In first operation, S[1] = 'a', so string becomes "aelloworld"
In first operation, S[8] = 'x', so string becomes "aellowoxld"
After performing Q operations, the string becomes "aellowoxld".
We have to perform M(=2) operations on the string "aellowoxld".
In first operation, we have to reverse the string lying between indices 2 and 3, so the string now becomes "alelowoxld". ("el" now becomes "le")
Similarly in second operation, we reverse the string lying between indices 2 and 4, so the string becomes "alelowoxld". ("lel" on reversing remains the same)
String str= "aellowoxld"
String fin= "alelowoxld"
No of characters same in both of them = 8.