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<bits/stdc++.h>

using namespace std;

struct {
    int sz, prior, lSon, rSon;
    bool rev;
    char c;
} t[300001];

int newNode(char c) {
    static int tw = 0;
    tw++;

    t[tw].sz = 1;
    t[tw].prior = rand();
    t[tw].c = c;

    return tw;
}

void push(int v) {
    if (t[v].rev) {
        t[v].lSon ^= t[v].rSon;
        t[v].rSon ^= t[v].lSon;
        t[v].lSon ^= t[v].rSon;

        t[t[v].lSon].rev ^= true;
        t[t[v].rSon].rev ^= true;

        t[v].rev = false;
    }
}

int merge(int l, int r) {
    if (min(l, r) == 0) return l + r;

    push(l);
    push(r);

    if (t[l].prior < t[r].prior) {
        t[l].sz += t[r].sz;
        t[l].rSon = merge(t[l].rSon, r);

        return l;
    }
    else {
        t[r].sz += t[l].sz;
        t[r].lSon = merge(l, t[r].lSon);

        return r;
    }
}

void split(int v, int k, int &l, int &r) {
    l = r = v;
    if (v == 0) return;

    push(v);

    if (t[t[v].lSon].sz >= k) {
        t[v].sz -= k;
        split(t[v].lSon, k, l, t[v].lSon);
    }
    else {
        t[v].sz = k;
        split(t[v].rSon, k - t[t[v].lSon].sz - 1, t[v].rSon, r);
    }
}

void dfs(int v) {
    if (v == 0) return;

    push(v);

    dfs(t[v].lSon);
    printf("%c", t[v].c);
    dfs(t[v].rSon);
}

char s[100001];

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        int n, q;
        scanf("%d %d %s", &n, &q, s);

        int root = 0;
        for (int i = 0; i < n; i++) root = merge(root, newNode(s[i]));

        for (int i = 0; i < q; i++) {
            int p, l, r;
            scanf("%d", &p);

            split(root, n - p, l, r);
            t[r].rev ^= true;

            root = merge(l, r);
        }

        dfs(root);

        printf("\n");
    }

    return 0;
}
```