Confidential Message
Difficulty: Hard

Yuo is a new student in his class.

The girls in his class apparently communicate information using a confidential process to somehow jumble the message.

Each jumbled message has a corresponding sequence of integers attached to it: $s_1, \ldots, s_N$. To "unjumble" the message, look at the last $s_1$ letters of the jumbled message and reverse their order to get a new jumbled message. Then, look at the last $s_2$ letters of this new message and reverse their order to get a new jumbled message and so on. After the final reversal, you should get the real unjumbled message.

Carly wanted to send a super secret SMS to her classmate Rae. Late night, while watching television, she finally decided she will send the SMS to her friend. But instead of texting Rae, she accidentally texted Yuo. Her text message reads:

<pre>
ireallyreallyreallyreallyreallyreallylikeyou
44 44 2 44 44

From:
Carly
09987765321
</pre>

Unlike her mobile service provider, Carly doesn't seem to be smart. Especially when you know how she got in this position.

Now, Yuo can perfectly read the sentence but he knows that girls speak in code. Thus, he can't be too sure what it means. So, he wants to unjumble the message to be certain. Can you create a program that unjumbles messages such as these for Yuo?


Input Format:
The first line of input contains an integer $T$, the number of test cases.

Each test case consists of three lines. The first line contains two integers $L$ and $N$, where $L$ is the length of the jumbled message (and of course, also the length of the unjumbled message). The second line contains a string $J$, the jumbled message. It is guaranteed to contain exactly $L$ characters and it only consists of lowercase letters from `a` to `z`. The third line consists the sequence $s_1, ..., s_N$ of $N$ integers.

Output Format:
For each test case, output a single line containing a string: the unjumbled message.  

**Constraints**  

$1 \le T \le 3$  
$1 \le s_i \le L$  

**Subtask 1** (8 points each):  
$1 \le L, N \le 20$  

**Subtask 2** (8 points each):  
$1 \le L, N \le 1000$  

**Subtask 3** (10 points each):  
$1 \le L, N \le 100000$  
$s_1 \geq s_2 \geq \cdots \geq s_N$

**Subtask 4** (10 points each):  
$1 \le L, N \le 100000$  
$s_1 \leq s_2 \leq \cdots \leq s_N$

**Subtask 5** (14 points each):  
$1 \le L, N \le 100000$  


Sample Input:
    3
    44 5
    ireallyreallyreallyreallyreallyreallylikeyou
    44 44 2 44 44
    6 3
    setter
    6 3 6
    13 8
    elevenplustwo
    3 13 11 8 9 6 7 2


Sample Output:
    ireallyreallyreallyreallyreallyreallylikeyuo
    tester
    twelveplusone
    

Python 3 starter code:


Reference solution (C++):
```cpp
#include <stdio.h>
#include <math.h>
#define LIM 100011
#define SLIM 1011

struct Piece {
    int i, length;
    bool back;
    Piece() {}
    Piece(int i, int length, bool back): i(i), length(length), back(back) {}

    int kth(int k) {
        return back ? i - k : i + k;
    }

    int end() {
        return kth(length - 1);
    }

    void reverse() {
        i = end();
        back = !back;
    }

    Piece split(int k) {
        Piece piece = Piece(kth(k), length - k, back);
        length = k;
        return piece;
    }
};

char *s = new char[LIM];
char *t = new char[LIM];
Piece pieces[SLIM];

int main() {
    int z;
    scanf("%d", &z);
    while (z--) {
        int n, q;
        scanf("%d%d%s", &n, &q, s);
        int sq = int(sqrt(n)) + 2;
        int l = 1;
        pieces[0] = Piece(0, n, false);
        #define flatten() do {\
            int idx = 0;\
            for (int I = 0; I < l; I++) {\
                for (int i = 0; i < pieces[I].length; i++) {\
                    t[idx++] = s[pieces[I].kth(i)];\
                }\
            }\
            char *u = s; s = t; t = u;\
            pieces[0] = Piece(0, n, false);\
            l = 1;\
        } while (0)

        while (q--) {
            int k;
            scanf("%d", &k);
            k = n-k;
            int idx = 0;
            while (k) {
                if (pieces[idx].length > k) {
                    for (int I = l-1; I > idx; I--) {
                        pieces[I+1] = pieces[I];
                    }
                    pieces[idx+1] = pieces[idx].split(k);
                    l++;
                }
                k -= pieces[idx++].length;
            }
            for (int I = idx, J = l-1; I < J; I++, J--) {
                Piece temp = pieces[I];
                pieces[I] = pieces[J];
                pieces[J] = temp;
            }
            for (int I = idx; I < l; I++) {
                pieces[I].reverse();
            }

            if (l == sq) flatten();
        }

        flatten();
        s[n] = 0;
        printf("%s\n", s);
    }
}
```