using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 3000000+10;

int test,n,pos,len;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];
int b[maxn];

void solve(int x, int y){
    ans[x] = b[0];
    int u = ne[x];
 //   debug(x);
    while (u <= y){
      //  cout << u << "    ";
        ans[ u ] = b[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
  //  cout << "\n";
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    scanf("%d", &test);
    int n = 0;
    FORE(i,1,test){
   //     cin >> s[i] >> k[i];
        cin >> s[i];
        scanf("%d", &k[i]);
        len = s[i].length();
        FORE(j, 1, k[i]){
            //cin >> pos;
            scanf("%d", &pos);
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        len = s[i].length();
        FOR(j,0,len) b[j] = s[i][j];
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1);
        }
    }
    string res = "";
    FORE(i,1,n){
        if (ans[i] == 0) res += 'a';
        else res += (char) ans[i];
    }
    cout << res;
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 1000000+10;

int test,n,pos,len;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];
int b[maxn];

void solve(int x, int y){
    ans[x] = b[0];
    int u = ne[x];
 //   debug(x);
    while (u <= y){
      //  cout << u << "    ";
        ans[u] = b[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
  //  cout << "\n";
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    scanf("%d", &test);
    int n = 0;
    FORE(i,1,test){
   //     cin >> s[i] >> k[i];
        cin >> s[i];
        scanf("%d", &k[i]);
        len = s[i].length();
        FORE(j,1,k[i]){
            //cin >> pos;
            scanf("%d", &pos);
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        len = s[i].length();
        FOR(j,0,len) b[j] = s[i][j];
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1);
        }
    }
    string res = "";
    FORE(i,1,n){
     //   if (ans[i] == 0) cout << "a";
     //   else cout << (char) ans[i];
        if (ans[i] == 0) res+='a';
        res+=(char)ans[i];
    }
    cout << res;
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

set<int> ss;
int test,n,pos;
int ans[3000000+10];
int vt[3000000+10];
int k[3000000+10];
string s[3000000+10];
vector<int> a[3000000 + 10];

void solve(int x, int y, int index){
   // cout << x << " " << y << "\n";
    set<int>::iterator it;
    while (!ss.empty()){
        it = ss.lower_bound(x);
        if (it!=ss.ED){
            if ( x <= *it && *it <= y ){
                ans[ *it ] = index;
                vt[*it] = (*it) - x + 1;
                ss.erase(it);
            }
            else break;
        }
        else break;
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n) ss.insert(i);
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, i);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
            string s2 = s[ ans[i] ];
            cout << s2[vt[i]-1];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 2000000+10;

int test,n,pos;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];

void solve(int x, int y, string s){
   // cout << x << " " << y << "\n";
    ans[x] = s[0];
    int u = ne[x];
    while (u <= y){
        ans[u] = s[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, s[i]);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else cout << (char) ans[i];
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 2000000+10;

int test,n,pos;
int ans[maxn];
int vt[maxn];
int k[maxn];
int pre[maxn];
int next[maxn];
string s[maxn];
vector<int> a[maxn];

void solve(int x, int y, int index){
   // cout << x << " " << y << "\n";
    ans[x] = index;
    vt[x] = 1;
    int u = next[x];
    while (u <= y){
        ans[u] = index;
        vt[u] = u - x + 1;
        next[ pre[u] ] = next[u];
        pre[ next[u] ] = pre[u];
        u = next[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        next[i] = i + 1;
    }
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, i);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
            string s2 = s[ ans[i] ];
            cout << s2[vt[i]-1];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 2000000+10;

int test,n,pos;
int ans[maxn];
int vt[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];

void solve(int x, int y, int index){
   // cout << x << " " << y << "\n";
    ans[x] = index;
    vt[x] = 1;
    int u = ne[x];
    while (u <= y){
        ans[u] = index;
        vt[u] = u - x + 1;
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, i);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
            string s2 = s[ ans[i] ];
            cout << s2[vt[i]-1];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

set<int> ss;
int test,n,k,pos;
int ans[2000000+10];
int vt[2000000+10];
string s[2000000+10];

void solve(int x, int y, int index){
   // cout << x << " " << y << "\n";
    set<int>::iterator it;
    while (!ss.empty()){
        it = ss.lower_bound(x);
        if (it!=ss.ED){
            if ( x <= *it && *it <= y ){
                ans[ *it ] = index;
                vt[*it] = (*it) - x + 1;
                ss.erase(it);
            }
            else break;
        }
        else break;
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,1000000) ss.insert(i);
    FORE(i,1,test){
        cin >> s[i] >> k;
        int len = s[i].length();
        FORE(j,1,k){
            cin >> pos;
            n = max(n, pos + len - 1);
            solve(pos, pos + len - 1, i);
        }
    }
  //  cout << n << "\n";
  //  FORE(i,1,n) cout << ans[i] << " ";
  //  FORE(i,1,n) cout << vt[i] << " ";
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
            string s2 = s[ ans[i] ];
            cout << s2[vt[i]-1];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 1500000+10;

int test,n,pos,len;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];
int b[maxn];

void solve(int x, int y){
   // cout << x << " " << y << "\n";
    ans[x] = b[0];
    int u = ne[x];
    while (u <= y){
        ans[u] = b[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        len = s[i].length();
        FOR(j,0,len) b[j] = s[i][j];
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else cout << (char) ans[i];
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 1000000+10;

int test,n,pos,len;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];
int b[maxn];

void solve(int x, int y){
    ans[x] = b[0];
    int u = ne[x];
 //   debug(x);
    while (u <= y){
      //  cout << u << "    ";
        ans[u] = b[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
  //  cout << "\n";
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    scanf("%d", &test);
    int n = 0;
    FORE(i,1,test){
   //     cin >> s[i] >> k[i];
        cin >> s[i];
        scanf("%d", &k[i]);
        len = s[i].length();
        FORE(j,1,k[i]){
            //cin >> pos;
            scanf("%d", &pos);
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        len = s[i].length();
        FOR(j,0,len) b[j] = s[i][j];
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1);
        }
    }
    string res = "";
    FORE(i,1,n){
     //   if (ans[i] == 0) cout << "a";
     //   else cout << (char) ans[i];
        if (ans[i] == 0) res+='a';
        else res+=(char)ans[i];
    }
    cout << res;
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 2000000 + 10;

set<int> ss;
int test,n,pos;
int ans[maxn];
int k[maxn];
string s[maxn];
vector<int> a[maxn];

void solve(int x, int y, int index){
    ans[x] = s[index][0];
    set<int>::iterator it;
    while (!ss.empty()){
        it = ss.lower_bound(x);
        if (it!=ss.ED){
            if ( x <= *it && *it <= y ){
                ans[ *it ] = s[index][ (*it) - x ];
                ss.erase(it);
            }
            else break;
        }
        else break;
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n) ss.insert(i);
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, i);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
            cout << (char) ans[i];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 1000000+10;

int test,n,pos;
int ans[maxn];
int vt[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];

void solve(int x, int y, int index){
   // cout << x << " " << y << "\n";
    ans[x] = index;
    vt[x] = 1;
    int u = ne[x];
    while (u <= y){
        ans[u] = index;
        vt[u] = u - x + 1;
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    cin >> test;
    int n = 0;
    FORE(i,1,test){
        cin >> s[i] >> k[i];
        int len = s[i].length();
        FORE(j,1,k[i]){
            cin >> pos;
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        int len = s[i].length();
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1, i);
        }
    }
    FORE(i,1,n){
        if (ans[i] == 0) cout << "a";
        else{
          //  string s2 = s[ ans[i] ];
            cout <<  s[ ans[i] ][vt[i]-1];
        }
    }
}


using namespace std;
#include<bits/stdc++.h>

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

const int maxn = 1500000+10;

int test,n,pos,len;
int ans[maxn];
int k[maxn];
int pre[maxn];
int ne[maxn];
string s[maxn];
vector<int> a[maxn];
int b[maxn];

void solve(int x, int y){
    ans[x] = b[0];
    int u = ne[x];
    while (u <= y){
        ans[u] = b[ u - x ];
        ne[ pre[u] ] = ne[u];
        pre[ ne[u] ] = pre[u];
        u = ne[u];
    }
}

int main(){
 //   freopen("codeforces.inp", "r", stdin);
 //   freopen(".out", "w", stdout);
    scanf("%d", &test);
    int n = 0;
    FORE(i,1,test){
   //     cin >> s[i] >> k[i];
        cin >> s[i];
        scanf("%d", &k[i]);
        len = s[i].length();
        FORE(j,1,k[i]){
            //cin >> pos;
            scanf("%d", &pos);
            a[i].PB(pos);
            n = max(n, pos + len - 1);
        }
    }
    FORE(i,1,n){
        pre[i] = i - 1;
        ne[i] = i + 1;
    }
    FORE(i,1,test){
        len = s[i].length();
        FOR(j,0,len) b[j] = s[i][j];
        FOR(j,0,k[i]){
            pos = a[i][j];
            solve(pos, pos + len - 1);
        }
    }
    FORE(i,1,n){
     //   if (ans[i] == 0) cout << "a";
     //   else cout << (char) ans[i];
        if (ans[i] == 0) printf("a");
        else printf("%c", (char)ans[i]);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
int dsu_get(int v){
    return p[v]==v ? v : dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=1e7;i++){
        p[i]=i;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<=x+s.size()-1;){
                ans[j]=s[j-x];
                j=p[dsu_get(j)]=dsu_get(j+1);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
inline int dsu_get(int v){
    if(!ans[v]){
        return v;
    }
    return p[v]=dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<=1e7;i++){
        p[i]=i+1;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            int y=x;
            mx=max(mx,y+(int)s.size()-1);
            x=dsu_get(x);
            for(int j=x;j<y+s.size();){
                ans[j]=s[j-y];
                j=dsu_get(j);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
int dsu_get(int v){
    return p[v]==v ? v : dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=1e7;i++){
        p[i]=i;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<=x+s.size()-1;j=p[j]){
                ans[j]=s[j-x];
                p[dsu_get(j)]=dsu_get(j+1);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
inline int dsu_get(int v){
    if(!ans[v]){
        return v;
    }
    return p[v]=dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<=1e7;i++){
        p[i]=i+1;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            int y=x;
            x=dsu_get(x);
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<x+s.size();){
                ans[j]=s[j-y];
                j=dsu_get(j);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
int dsu_get(int v){
    return p[v]==v ? v : dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=1e7;i++){
        p[i]=i;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            x=dsu_get(x);
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<=x+s.size()-1;){
                ans[j]=s[j-x];
                j=p[dsu_get(j)]=dsu_get(j+1);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
int dsu_get(int v){
    return p[v]==v ? v : dsu_get(p[v]);
}
inline void dsu_unite(int a,int b){
    a=dsu_get(a),b=dsu_get(b);
    if(a==b){
        return;
    }
    p[a]=b;
    return;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=1e7;i++){
        p[i]=i;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<=x+s.size()-1;j=dsu_get(j)){
                ans[j]=s[j-x];
                dsu_unite(j,j+1);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
inline int dsu_get(int v){
    if(!ans[v]){
        return v;
    }
    return p[v]=dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<=1e7;i++){
        p[i]=i+1;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            int y=x;
            x=dsu_get(x);
            mx=max(mx,y+(int)s.size()-1);
            for(int j=x;j<x+s.size();){
                ans[j]=s[j-y];
                j=dsu_get(j);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,k,x,mx,p[N];
string s;
char ans[N];
int dsu_get(int v){
    return p[v]==v ? v : dsu_get(p[v]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=1e6;i++){
        p[i]=i;
    }
    for(int i=1;i<=n;i++){
        cin>>s>>k;
        while(k--){
            cin>>x;
            mx=max(mx,x+(int)s.size()-1);
            for(int j=x;j<=x+s.size()-1;){
                ans[j]=s[j-x];
                j=p[dsu_get(j)]=dsu_get(j+1);
            }
        }
    }
    for(int i=1;i<=mx;i++){
        cout<<(ans[i] ? ans[i] : 'a');
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[100010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size) printf("%c", ans[i]);
    puts("");
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[1000010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, (int)str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][(int)str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size-1) printf("%c", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[1000010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, (int)str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][(int)str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size) printf("%c", ans[i]);
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[1000010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, (int)str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][(int)str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second && len[i].second-1 > 0) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size) printf("%c", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[100010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size) printf("%c", ans[i]);
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[1000010];
char ans[1000010];
string str[1000010];
P len[1000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 1000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, (int)str[i].size());
            }
        }
    }

    for(int i = 0; i < 1000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][(int)str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 1000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    printf("%s\n", ans);
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char buf[2000010];
char ans[2000010];
string str[2000010];
P len[2000010];

int main(){
    scanf("%d", &n);
    for(int i = 0; i < 2000010; i++) {
        len[i] = P(-1, -1);
    }
    rep(i,n) {
        int k;
        scanf("%s %d", buf, &k);
        str[i] = buf;
        rep(j,k) {
            int x;
            scanf("%d", &x);
            x--;
            if(len[x].second < (int)str[i].size()) {
                len[x] = P(i, (int)str[i].size());
            }
        }
    }

    for(int i = 0; i < 2000005; i++) {
        if(len[i].second == -1) {
            ans[i] = '_';
            continue;
        }
        ans[i] = str[len[i].first][(int)str[len[i].first].size()-len[i].second];
        if(len[i].second-1 > len[i+1].second && len[i].second-1 > 0) {
            len[i+1] = P(len[i].first, len[i].second-1);
        }
    }
    int size;
    for(int i = 2000004; i >= 0; i--) {
        if(ans[i] == '_') {
            continue;
        }
        size = i+1;
        break;
    }
    rep(i,size) if(ans[i] == '_') ans[i] = 'a';
    rep(i,size) printf("%c", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
   }
   sort(all(v));
   vector<char> res(sz, 'a');
   int last = 0;
   for (int i = 0; i < v.size(); i++)
   {
      string s = st[v[i].ss.ss];
      int l = s.length();
      if (v[i].ff > last)
      {
         for (int j = 0; j < l; j++)
         {
            res[v[i].ff + j] = s[j];
         }
         last = v[i].ss.ff;
      }
      else if (v[i].ff <= last && v[i].ss.ff > last)
      {
         int diff = last - v[i].ff + 1;
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
         last = v[i].ss.ff; //motherfucker
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << char(tolower(res[i]));
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, i});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   if (n == 1 && st[0].size() > 100)
   {
      cout << sz << " " << len << "\n";
      for (int i = 0; i < len; i++)
      {
         cout << "aya\n";
      }
      return;
   }
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss];
      int sta = v[i].ff, en = v[i].ff + s.length() - 1;
      if (sta > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
      else if (sta <= last && en > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   if (n == 1 && st[0].size() > 100)
   {
      cout << "aya\n";
      return;
   }
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
vector<char> res(MAX, 'A');
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
   }
   sort(all(v));

   int last = 0;
   for (int i = 0; i < v.size(); i++)
   {
      string s = st[v[i].ss.ss];
      int l = s.length();
      if (v[i].ff > last)
      {
         for (int j = 0; j < l; j++)
         {
            res[v[i].ff + j] = s[j];
         }
         last = v[i].ss.ff;
      }
      else if (v[i].ff <= last && v[i].ss.ff > last)
      {
         int diff = last - v[i].ff + 1;
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << char(tolower(res[i]));
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
      if (n == 1 && st[0].size() > 100)
      {
         cout << x.size() << " " << k << " " << sz << "\n";
         // return;
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));

   int last = 0, len = v.size();
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss.ss];
      int l = s.length();
      int sta = v[i].ff, en = v[i].ss.ff;
      if (sta > last)
      {
         if (n == 1 && st[0].size() > 100)
         {
            // cout << x.size() << " " << k << " " << sz << "\n";
            cout << l << "\n";
            continue;
            // return;
         }
         for (int j = 0; j < l; j++)
         {
            res[sta + j] = s[j];
         }
         last = en;
      }
      else if (sta <= last && en > last)
      {
         int diff = last - sta + 1;
         if (n == 1 && st[0].size() > 100)
         {
            // cout << x.size() << " " << k << " " << sz << "\n";
            cout << en - last << "\n";
            continue;
            // return;
         }
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
         last = en; //motherfucker
      }
      if (last == sz - 1)
         break;
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, i});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss];
      int sta = v[i].ff, en = v[i].ff + s.length() - 1;
      if (sta > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
      else if (sta <= last && en > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   if (n == 1 && st[0].size() > 100)
   {
      cout << "aya\n";
      return;
   }
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


/*
 *Author--architect034
 *NIT Silchar
 */
#include<bits/stdc++.h>
using namespace std;
#define fast   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll   long long
#define loop(i,start,end,increment)   for(int i=start;i<=end;i+=increment)
#define ulta(i,start,end,decrement)  for(int i=start;i>=end;i-=decrement)
#define pb   push_back
#define popb   pop_back
#define pf   push_front
#define popf   pop_front
#define mp   make_pair
#define FF   first
#define SS   second
#define all(something)   something.begin(),something.end()
#define veci   vector<int>
#define vecll   vector<ll>
#define setll   set<ll>
#define mapll   map<ll,ll>
#define vecitr   vector<ll>::iterator
#define setitr   set<ll>::iterator
#define mapitr   map<ll,ll>::iterator
#define stop   return 0;
#define mod   1000000007
void debug(string s)
{
	cout<<s<<"\n";
}
vecll prime;
void sieve()
{
	bool arr[1000008];
	memset(arr,1,sizeof(arr));
	arr[0]=arr[1]=0;
	loop(i,2,sqrt(1000008),1)
	{
		if(arr[i]==1)
		{
			loop(j,i*i,1000007,i)
			{
				arr[j]=0;
			}
		}
	}
	loop(i,2,1000007,1)
	{
		if(arr[i]==1)
		{
			prime.pb(i);
		}
	}
}
ll GCD(ll a,ll b)
{
	ll c=a%b;
	while(c!=0)
	{
		a=b;
		b=c;
		c=a%b;
	}
	return b;
}
ll power(ll a,ll b)
{
	ll ans=1;
	while(b!=0)
	{
		if(b%2==1)
		{
			ans*=a;
		}
		a*=a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	fast;
	int n;
	cin>>n;
	vector<string> v;
	string s;
	char ans[1000001]={'0'};
	int kaha=-1;
	loop(i,0,n-1,1)
	{
		cin>>s;
		int kitna;
		cin>>kitna;
		loop(j,0,kitna-1,1)
		{
			int x;
			cin>>x;
			// strt=min(strt,x-1);
			int len=s.length();
			kaha=max(kaha,len+x);
			// cout<<"KAHA -- "<<kaha<<"\n";
			for(int k=x-1,cnt=0;cnt<len;cnt++,k++)
			{
				ans[k]=s[cnt];
			}
		}
	}
	loop(i,0,kaha-2,1)
	{
		// cout<<"i -- "<<i<<"\n";
		if(!(ans[i]>='a' && ans[i]<='z'))
		{
			// debug("aya");
			cout<<"a";
			continue;
		}
		cout<<ans[i];
	}
	stop;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   string x;
   vector<char> res(MAX, 'a');
   for (int i = 0; i < n; i++)
   {
      string st;
      cin >> st;
      int k, l = st.length();
      cin >> k;
      int start = 0, f;
      for (int j = 0; j < k; j++)
      {

         cin >> f;
         start = max(start, f);
         for (int kt = start; kt < f + l; kt++)
         {
            res[kt] = st[kt - f];
         }
         start = f + l;
      }
      sz = max(sz, f + l);
   }

   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, i});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss];
      int sta = v[i].ff, en = v[i].ff + s.length() - 1;
      if (en > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   vector<char> res(MAX, 'a');
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      int start = 0, f;
      for (int j = 0; j < k; j++)
      {

         cin >> f;
         start = max(start, f);
         for (int j = start; j < start + l; j++)
         {
            res[j] = st[i][j - f];
         }
         start += l;
      }
      sz = max(sz, f + l);
   }

   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<string> st(n);
   vector<int> idx(MAX, -1);
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         idx[f] = i;
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');

   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, i});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss];
      int sta = v[i].ff, en = v[i].ff + s.length() - 1;
      if (sta > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
      else if (sta <= last && en > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   if (n == 1 && st[0].size() > 100)
   {
      cout << "aya\n";
      return;
   }
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, int>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> st[i];
      int k, l = st[i].length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, i});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   if (n == 1 && st[0].size() > 100)
   {
      for (int i = 0; i < sz; i++)
      {
         cout << "AYA\n";
      }
      return;
   }
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss];
      int sta = v[i].ff, en = v[i].ff + s.length() - 1;
      if (sta > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
      else if (sta <= last && en > last)
      {
         idx[sta] = v[i].ss;
         last = en;
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   if (n == 1 && st[0].size() > 100)
   {
      cout << "aya\n";
      return;
   }
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve();
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   string x;
   for (int i = 0; i < n; i++)
   {

      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
   }
   vector<char> res(sz, 'a');
   sort(all(v));
   vector<int> idx(sz, -1);
   int last = 0, len = v.size();
   for (int i = 0; i < len; i++)
   {
      string s = st[v[i].ss.ss];
      int sta = v[i].ff, en = v[i].ss.ff;
      if (sta > last)
      {
         idx[sta] = v[i].ss.ss;
         last = en;
      }
      else if (sta <= last && en > last)
      {
         idx[sta] = v[i].ss.ss;
         last = en; //motherfucker
      }
   }
   // for (int i = 1; i < sz; i++)
   // {
   //    cout << idx[i] << " ";
   // }
   // nl;
   for (int i = 1; i < sz; i++)
   {
      if (idx[i] != -1)
      {
         string x = st[idx[i]];
         idx[i] = -1;
         int l = x.size();
         for (int j = 0; j < l; j++, i++)
         {
            if (idx[i] == -1)
               res[i] = x[j];
            else
            {
               i--;
               break;
            }
         }
         i--;
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << res[i];
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
vector<char> res(3000010, 'A');
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
   }
   sort(all(v));

   int last = 0;
   for (int i = 0; i < v.size(); i++)
   {
      string s = st[v[i].ss.ss];
      int l = s.length();
      if (v[i].ff > last)
      {
         for (int j = 0; j < l; j++)
         {
            res[v[i].ff + j] = s[j];
         }
         last = v[i].ss.ff;
      }
      else if (v[i].ff <= last && v[i].ss.ff > last)
      {
         int diff = last - v[i].ff + 1;
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << char(tolower(res[i]));
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e7 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, int>>> v;
   vector<string> st(n);
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      st[i] = x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, i}});
         sz = max(sz, f + l);
      }
   }
   sort(all(v));
   vector<char> res(sz, 'a');
   int last = 0;
   for (int i = 0; i < v.size(); i++)
   {
      string s = st[v[i].ss.ss];
      int l = s.length();
      if (v[i].ff > last)
      {
         for (int j = 0; j < l; j++)
         {
            res[v[i].ff + j] = s[j];
         }
         last = v[i].ss.ff;
      }
      else if (v[i].ff <= last && v[i].ss.ff > last)
      {
         int diff = last - v[i].ff + 1;
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << char(tolower(res[i]));
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define f(i, st, en, in) for (ll i = st; i <= en; i += in)
#define rf(i, st, en, de) for (ll i = st; i >= en; i -= de)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(something) something.begin(), something.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ps(x) cout << x << " "
#define pl(x) cout << x << endl
#define nl cout << endl
using namespace std;
const int MAX = 1e5 + 9;
const ll mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve()
{
   prime[0] = prime[1] = 0;
   spf[2] = 2;
   f(i, 4, MAX - 1, 2)
   {
      spf[i] = 2;
      prime[i] = 0;
   }
   primes.pb(2);
   f(i, 3, MAX - 1, 2)
   {
      if (prime[i])
      {
         primes.pb(i);
         spf[i] = i;
         f(j, i * i, MAX - 1, i)
         {
            prime[j] = 0;
            if (spf[j] == 1)
            {
               spf[j] = i;
            }
         }
      }
   }
}
ll power(ll a, ll b)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = res * a;
      }
      a = a * a;
      b = b >> 1;
   }
   return res;
}
ll power(ll a, ll b, ll m)
{
   ll res = 1;
   while (b)
   {
      if (b & 1)
      {
         res = (res * a) % m;
      }
      a = (a * a) % m;
      b = b >> 1;
   }
   return res % m;
}
void pre()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
void solve(int tc)
{
   // cout << "Case #" << tc << ": ";
   int n, sz = 0;
   cin >> n;
   vector<pair<int, pair<int, string>>> v;
   for (int i = 0; i < n; i++)
   {
      string x;
      cin >> x;
      int k, l = x.length();
      cin >> k;
      for (int j = 0; j < k; j++)
      {
         int f;
         cin >> f;
         v.pb({f, {f + l - 1, x}});
         sz = max(sz, f + l);
      }
   }
   sort(all(v));
   vector<char> res(sz, 'A');

   int last = 0;
   for (int i = 0; i < v.size(); i++)
   {
      string s = v[i].ss.ss;
      int l = s.length();
      if (v[i].ff > last)
      {
         for (int j = 0; j < l; j++)
         {
            res[v[i].ff + j] = s[j];
         }
         last = v[i].ss.ff;
      }
      else if (v[i].ff <= last && v[i].ss.ff > last)
      {
         int diff = last - v[i].ff + 1;
         for (int j = diff, cnt = 1; j < l; j++, cnt++)
         {
            res[last + cnt] = s[j];
         }
      }
   }
   for (int i = 1; i < sz; i++)
   {
      cout << char(tolower(res[i]));
   }
}
int main()
{
   ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   pre();
   int test_cases = 1;
   // cin >> test_cases;
   for (int i = 1; i <= test_cases; i++)
   {
      solve(i);
   }
   return 0;
}