[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare integer variable n
declare string t
declare int k
create int ans_len
create char array str with 20 * 100010 elements
create int array chars s with size 80 * 100010
function push_up with int argument rt
    chars[rt] = chars[rt << 1] + chars[rt << 1 | 1]
end of the block
void function update with int arguments L, R, left, right and rt
    if chars[rt] >= right - left + 1, return
    if left is equal to right
        create char array s with rt elements
        set str[left] to t[left - L]
        return
    end of the block
    if L > right or R < left, return
    int mid = (left + right) >> 1
    if mid >= R
        call update with arguments L, R, left, mid and rt << 1
    else if mid is less than L
        call update with arguments L, R, mid + 1, right and rt << 1 | 1
    else
        call update with arguments L, R, left, mid and rt << 1
        call update with arguments L, R, mid + 1, right and rt << 1 | 1
    end of the block
    call push_up(rt)
end of the block
define the main function
    create int pos
    declare integer endpos
    read n and loop further
        change ans_len to 0
        for i from 1 to 2000010 exclusive, assign 'a' to str[i]
        set sizeof(chars) bytes at the pointer chars to 0
        for i from 1 to n inclusive
            read input to t and k
            loop j from 1 to k inclusive
                read pos
                set endpos to pos + length of t - 1
                call update with arguments pos, endpos, 1, 2000010 and 1
                if j = k
                    change ans_len to endpos if endpos is greater than ans_len
                end of the block
            end of the block
        end of the block
        for i from 1 to ans_len inclusive, print str[i]
        print new line
    end of the block
end of the block

[CODE]:

int n;
string t;
int k;
int ans_len;
char str[20 * 100010];
int chars[80 * 100010];
void push_up(int rt) {
    chars[rt] = chars[rt << 1] + chars[rt << 1 | 1];
}
void update(int L, int R, int left, int right, int rt) {
    if (chars[rt] >= right - left + 1) return;
    if (left == right) {
        chars[rt] = 1;
        str[left] = t[left - L];
        return;
    }
    if (L > right || R < left) return;
    int mid = (left + right) >> 1;
    if (mid >= R)
        update(L, R, left, mid, rt << 1);
    else if (mid < L)
        update(L, R, mid + 1, right, rt << 1 | 1);
    else {
        update(L, R, left, mid, rt << 1);
        update(L, R, mid + 1, right, rt << 1 | 1);
    }
    push_up(rt);
}
int main() {
    int pos;
    int endpos;
    while (cin >> n) {
        ans_len = 0;
        for (int i = 1; i < 2000010; i++) str[i] = 'a';
        memset(chars, 0, sizeof(chars));
        for (int i = 1; i <= n; i++) {
            cin >> t >> k;
            for (int j = 1; j <= k; j++) {
                cin >> pos;
                endpos = pos + t.length() - 1;
                update(pos, endpos, 1, 2000010, 1);
                if (j == k) {
                    if (endpos > ans_len) ans_len = endpos;
                }
            }
        }
        for (int i = 1; i <= ans_len; i++) cout << str[i];
        cout << endl;
    }
}