SP21178 TAP2014K - Encryption kit

Description

**\[Due to SPOJ restrictions, this problem has been modified with respect to the original version used in the Argentinian Programming Tournament of 2014 in order to have multiple test cases per input file. The original version of this problem (in Spanish) can be found at [http://dc.uba.ar/events/icpc/download/problems/tap2014-problems.pdf](http://dc.uba.ar/events/icpc/download/problems/tap2014-problems.pdf "http://dc.uba.ar/events/icpc/download/problems/tap2014-problems.pdf") \]** Karina is developing a powerful encryption protocol. To make it available to a wider audience, she wants to implement a tool-kit to make it easier to use. In particular, she requires a tool capable of efficiently performing a complicated operation over strings.

Input Format

The first line contains an integer number **T**, the number of test cases (**1 ). **T** test cases follow.** The first line of each test case contains the initial string **S**, composed of between **2** and **10 $ ^{5} $** lower-case letters of the English alphabet, and an integer **N**, representing the number of operations that are to be performed (**1** ****N** ****10 $ ^{5} $** ).**** The following **N** lines contain the description of one operation each, given by four integers **I, J, K** and **L** representing the four positions in the string for the operation explained above (**1** ****I** ****J < K** ****L** ****|S|** with **|S|** the length of the string **S**).********

Output Format

For each test case, print a single line containing a string representing the resulting string obtained after succesively applying all the operations in the input to the given initial string.