#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5+10;
const int M=2e6+10;
const int BC=1420;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int len;
};
info S[N];
Block B[BC];
int belong[M],unit,bcnt,maxlen;
pii arr[M];
vector<int>ST[N];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
        B[i].st=1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id, arr[i].second=st;
        B[bl].id=-1;
        if(r-l+1==B[bl].r-B[bl].l+1)
            B[bl].id=id, B[bl].st=st;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        if(l==B[bl].l)
            B[bl].id=id, B[bl].st=st;
        if(r==B[br].r)
            B[br].id=id, B[br].st=st;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1&&arr[x].first==0)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                int _st;
                scanf("%d",&_st);
                ST[i].push_back(_st);
                maxlen=max(maxlen,S[i].len+_st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5;
const int M=2e6+7;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int st,len;
};
info S[N];
Block B[345];
int belong[1000010],unit,bcnt,maxlen;
pii arr[1000010];
vector<int>ST[N];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        B[bl].id=-1;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                scanf("%d",&S[i].st);
                ST[i].push_back(S[i].st);
                maxlen=max(maxlen,S[i].len+S[i].st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
            {
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
            }
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5;
const int M=2e6+7;
const int BC=1010;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int st,len;
};
info S[M];
Block B[M];
int belong[M],unit,bcnt,maxlen;
pii arr[M];
vector<int>ST[N];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        B[bl].id=-1;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                scanf("%d",&S[i].st);
                ST[i].push_back(S[i].st);
                maxlen=max(maxlen,S[i].len+S[i].st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
            {
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
            }
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 10;
const int M = 2e6 + 10;
const int BC = 1420;
struct Block
{
	int l, r;
	int id, st;
};
struct info
{
	string s;
	int len;
};
info S[N];
Block B[BC];
int belong[M], unit, bcnt, maxlen;
pii arr[M];
vector<int>ST[N];

void init()
{
	bcnt = maxlen / unit;
	if (maxlen % unit)
		++bcnt;
	int i;
	for (i = 1; i <= bcnt; ++i)
	{
		B[i].l = (i - 1) * unit + 1;
		B[i].r = i * unit;
		B[i].id = -1;
		B[i].st = 1;
	}
	B[bcnt].r = maxlen;
	for (i = 1; i <= maxlen; ++i)
		belong[i] = (i - 1) / unit + 1;
}
void pushdown(int bx)
{
	if(B[bx].id!=-1)
	{
		for (int i=B[bx].l; i<=B[bx].r; ++i)
			arr[i].first=B[bx].id, arr[i].second=B[bx].st;
		B[bx].id=-1;
		B[bx].st=1;
	}
}
void update(int l, int r, int id, int st)
{
	int bl = belong[l], br = belong[r];
	if (bl == br)
	{
		pushdown(bl);
		for (int i = l; i <= r; ++i)
			arr[i].first = id, arr[i].second = st;
	}
	else
	{
		pushdown(bl);
		pushdown(br);
		for (int i = l; i <= B[bl].r; ++i)
			arr[i].first = id, arr[i].second = st;
		for (int i = B[br].l; i <= r; ++i)
			arr[i].first = id, arr[i].second = st;
		for (int i = bl + 1; i < br; ++i)
			B[i].id = id, B[i].st = st;
	}
}
pii query(int x)
{
	int bx = belong[x];
	pushdown(bx);
	return arr[x];
}
int main(void)
{
	int n, k, i;
	while (~scanf("%d", &n))
	{
		maxlen = 0;
		for (i = 1; i <= n; ++i)
		{
			cin >> S[i].s;
			S[i].len = S[i].s.size();
			scanf("%d", &k);
			while (k--)
			{
				int _st;
				scanf("%d", &_st);
				ST[i].push_back(_st);
				maxlen = max(maxlen, S[i].len + _st - 1);
			}
		}
		unit = sqrt(maxlen);
		init();
		for (i = 1; i <= n; ++i)
		{
			int sz = ST[i].size();
			for (int j = 0; j < sz; ++j)
				update(ST[i][j], ST[i][j] + S[i].len - 1, i, ST[i][j]);
		}
		for (i = 1; i <= maxlen; ++i)
		{
			pii c = query(i);
			if (c.first == 0)
				putchar('a');
			else
				printf("%c", S[c.first].s[i - c.second]);
		}
		puts("");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5+10;
const int M=2e6+7;
const int BC=1010;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int st,len;
};
info S[M];
Block B[M];
int belong[M],unit,bcnt,maxlen;
pii arr[M];
vector<int>ST[M];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        B[bl].id=-1;
        if(r-l+1==B[bl].r-B[bl].l+1)
            B[bl].id=id, B[bl].st=st;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        if(l==B[bl].l)
            B[bl].id=id, B[bl].st=st;
        if(r==B[br].r)
            B[br].id=id, B[br].st=st;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                scanf("%d",&S[i].st);
                ST[i].push_back(S[i].st);
                maxlen=max(maxlen,S[i].len+S[i].st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
            {
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
            }
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5;
const int M=2e6+7;
const int BC=1010;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int st,len;
};
info S[N];
Block B[BC];
int belong[1000010],unit,bcnt,maxlen;
pii arr[1000010];
vector<int>ST[N];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        B[bl].id=-1;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                scanf("%d",&S[i].st);
                ST[i].push_back(S[i].st);
                maxlen=max(maxlen,S[i].len+S[i].st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
            {
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
            }
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5+10;
const int M=2e6+7;
const int BC=1010;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int st,len;
};
info S[M];
Block B[M];
int belong[M],unit,bcnt,maxlen;
pii arr[M];
vector<int>ST[M];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        B[bl].id=-1;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id,arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                scanf("%d",&S[i].st);
                ST[i].push_back(S[i].st);
                maxlen=max(maxlen,S[i].len+S[i].st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
            {
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
            }
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 10;
const int M = 2e6 + 10;
const int BC = 1420;
struct Block
{
	int l, r;
	int id, st;
};
struct info
{
	string s;
	int len;
};
info S[N];
Block B[BC];
int belong[M], unit, bcnt, maxlen;
pii arr[M];
vector<int>ST[N];

void init()
{
	bcnt = maxlen / unit;
	if (maxlen % unit)
		++bcnt;
	int i;
	for (i = 1; i <= bcnt; ++i)
	{
		B[i].l = (i - 1) * unit + 1;
		B[i].r = i * unit;
		B[i].id = -1;
		B[i].st = 1;
	}
	B[bcnt].r = maxlen;
	for (i = 1; i <= maxlen; ++i)
		belong[i] = (i - 1) / unit + 1;
}
inline void pushdown(int bx)
{
	if(B[bx].id!=-1)
	{
		for (int i=B[bx].l; i<=B[bx].r; ++i)
			arr[i].first=B[bx].id, arr[i].second=B[bx].st;
		B[bx].id=-1;
		B[bx].st=1;
	}
}
void update(int l, int r, int id, int st)
{
	int bl = belong[l], br = belong[r];
	if (bl == br)
	{
		pushdown(bl);
		for (int i = l; i <= r; ++i)
			arr[i].first = id, arr[i].second = st;
	}
	else
	{
		pushdown(bl);
		pushdown(br);
		for (int i = l; i <= B[bl].r; ++i)
			arr[i].first = id, arr[i].second = st;
		for (int i = B[br].l; i <= r; ++i)
			arr[i].first = id, arr[i].second = st;
		for (int i = bl + 1; i < br; ++i)
			B[i].id = id, B[i].st = st;
	}
}
pii query(int x)
{
	int bx = belong[x];
	pushdown(bx);
	return arr[x];
}
int main(void)
{
	FAST_IO
	int n, k, i;
	while (cin>>n)
	{
		maxlen = 0;
		for (i = 1; i <= n; ++i)
		{
			cin >> S[i].s;
			S[i].len = S[i].s.size();
			cin>>k;
			while (k--)
			{
				int _st;
				cin>>_st;
				ST[i].push_back(_st);
				maxlen = max(maxlen, S[i].len + _st - 1);
			}
		}
		unit = sqrt(maxlen);
		init();
		for (i = 1; i <= n; ++i)
		{
			int sz = ST[i].size();
			for (int j = 0; j < sz; ++j)
				update(ST[i][j], ST[i][j] + S[i].len - 1, i, ST[i][j]);
		}
		for (i = 1; i <= maxlen; ++i)
		{
			pii c = query(i);
			if (c.first == 0)
				cout<<'a';
			else
				cout<<S[c.first].s[i - c.second];
		}
		cout<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int,int> pii;
typedef long long LL;
const double PI=acos(-1.0);
const int N=1e5+10;
const int M=2e6+10;
const int BC=1e3+10;
struct Block
{
    int l,r;
    int id,st;
};
struct info
{
    string s;
    int len;
};
info S[N];
Block B[BC];
int belong[M],unit,bcnt,maxlen;
pii arr[M];
vector<int>ST[N];

void init()
{
    bcnt=maxlen/unit;
    if(maxlen%unit)
        ++bcnt;
    int i;
    for (i=1; i<=bcnt; ++i)
    {
        B[i].l=(i-1)*unit+1;
        B[i].r=i*unit;
        B[i].id=-1;
        B[i].st=1;
    }
    B[bcnt].r=maxlen;
    for (i=1; i<=maxlen; ++i)
        belong[i]=(i-1)/unit+1;
}
void update(int l,int r,int id,int st)
{
    int bl=belong[l],br=belong[r];
    if(bl==br)
    {
        for (int i=l; i<=r; ++i)
            arr[i].first=id, arr[i].second=st;
        B[bl].id=-1;
        if(r-l+1==B[bl].r-B[bl].l+1)
            B[bl].id=id, B[bl].st=st;
    }
    else
    {
        B[bl].id=-1;
        B[br].id=-1;
        if(l==B[bl].l)
            B[bl].id=id, B[bl].st=st;
        if(r==B[br].r)
            B[br].id=id, B[br].st=st;
        for (int i=l; i<=B[bl].r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=B[br].l; i<=r; ++i)
            arr[i].first=id, arr[i].second=st;
        for (int i=bl+1; i<br; ++i)
            B[i].id=id, B[i].st=st;
    }
}
pii query(int x)
{
    int bx=belong[x];
    if(B[bx].id!=-1&&arr[x].first==0)
        return pii(B[bx].id,B[bx].st);
    else
        return arr[x];
}
int main(void)
{
    int n,k,i;
    while (~scanf("%d",&n))
    {
        maxlen=0;
        for (i=1; i<=n; ++i)
        {
            cin>>S[i].s;
            S[i].len=S[i].s.size();
            scanf("%d",&k);
            while (k--)
            {
                int _st;
                scanf("%d",&_st);
                ST[i].push_back(_st);
                maxlen=max(maxlen,S[i].len+_st-1);
            }
        }
        unit=sqrt(maxlen);
        init();
        for (i=1; i<=n; ++i)
        {
            int sz=ST[i].size();
            for (int j=0; j<sz; ++j)
                update(ST[i][j],ST[i][j]+S[i].len-1,i,ST[i][j]);
        }
        for (i=1; i<=maxlen; ++i)
        {
            pii c=query(i);
            if(c.first==0)
                putchar('a');
            else
                printf("%c",S[c.first].s[i-c.second]);
        }
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[1000005]={};

	while(n--)
	{
	    cin>>s>>k;
	    int curr=s.size(),done=-curr;
	    while(k--)
	    {
	        scanf("%d",&start);
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}
	int i;
	for(i=1000004;!ans[i];)i--;
	for(int j=1;j<=i;j++) putchar(ans[j]?ans[j]:'a');

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<pair<int,string>> str;

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     str.pb(mp(a-1,sub));
	     len=max(len,a-1+sub.length());
	    }
	}

    sort(str.begin(),str.end());

	FOR(i,len) ans=ans+"a";

	ll pced=-1;

	for(int i=0;i<str.size();)
	{
	    int start=str[i].ff,gst=str[i].ss.length(),ind=i;
	    while(i<str.size() && str[i].ff==start)
	    {
	        if(str[i].ss.length()>gst)
	        {
	            gst=str[i].ss.length();
	            ind=i;
	        }
	        i++;
	    }

	    if(pced<start+str[ind].ss.length())
	    {
	    for(int j=0;j<str[ind].ss.length();j++)
	    {
	        ans[j+start]=(str[ind].ss)[j];
	    }
	    pced=start+str[ind].ss.length()-1;
	    }

	}
	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[2000005]={'?'};

	for(int i=0;i<2000005;i++)
	{
	    ans[i]='?';
	}

	while(n--)
	{
	    cin>>s>>k;

	    while(k--)
	    {
	        cin>>start;
	        start--;
	        for(int i=0;i<s.length();i++)
	        {
	            ans[start+i]=s[i];
	        }
	    }
	}

	ll len=0;

	for(int i=1000004;i>=0;i--)
	{
	    if(ans[i]!='?') len=max(len,i);
	}

	for(int i=0;i<=len;i++)
	{
	    if(ans[i]=='?') cout<<"a";
	    else cout<<ans[i];
	}

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<string> str[1000005];

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     a--;
	     if(str[a].size()==0) {str[a].pb(sub);len=max(len,a+sub.length());}
	     else
	     {
	      int len2=str[a][0].length(),curr=sub.length();
	      str[a][0]=(curr>len2)? sub:str[a][0];
	      len=max(len,a+str[a][0].length());
	     }
	    }
	}

	//cout<<len;

	FOR(i,len) ans=ans+"a";

// 	ll rec=0;

// 	for(int i=0;i<len;i++)
// 	{
// 	    if(str[i].size()==0) {continue;}

// 	    if(rec<=i+str[i][0].length()-1)
// 	    {
// 	    int j=rec-i;
// 	    for(;j<str[i][0].length();j++)
// 	    {
// 	     ans[i+j]=(str[i][0])[j];
// 	    }
// 	    rec=i+str[i][0].length();
// 	    }
// 	}

	ll pced=-1;

	for(int i=0;i<len;)
	{
	    if(str[i].size()==0) {i++;continue;}
	    if(pced<i+str[i][0].length())
	    {
	    int j=0;
	    if(pced>i) j=pced-i+1;
	    for(;j<str[i][0].length();j++)
	    {
	        ans[j+i]=(str[i][0])[j];
	    }
	    pced=max(pced,i+str[i][0].length()-1);
	    }
	    i++;
	}

	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<string> str[1000005];

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     a--;
	     if(str[a].size()==0) {str[a].pb(sub);len=max(len,a+sub.length());}
	     else
	     {
	      int len2=str[a][0].length(),curr=sub.length();
	      str[a][0]=(curr>len2)? sub:str[a][0];
	      len=max(len,a+str[a][0].length());
	     }
	    }
	}

	//cout<<len;

	FOR(i,len) ans=ans+"a";

	ll rec=0;

	for(int i=0;i<len;i++)
	{
	    if(str[i].size()==0) {continue;}

	    if(rec<=i+str[i][0].length())
	    {
	    int j=rec-i;
	    for(;j<str[i][0].length();j++)
	    {
	     ans[i+j]=(str[i][0])[j];
	    }
	    rec=i+str[i][0].length();
	    }
	}

	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<string> str[1000005];

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     a--;
	     if(str[a].size()==0) {str[a].pb(sub);len=max(len,a+sub.length());}
	     else
	     {
	      int len2=str[a][0].length(),curr=sub.length();
	      str[a][0]=(curr>len2)? sub:str[a][0];
	      len=max(len,a+str[a][0].length());
	     }
	    }
	}

	//cout<<len;

	FOR(i,len) ans=ans+"a";

	for(int i=0;i<len;i++)
	{
	    if(str[i].size()==0) continue;

	    for(int j=0;j<str[i][0].length();j++)
	    {
	     ans[i+j]=(str[i][0])[j];
	    }
	}

	cout<<ans;

//     sort(str.begin(),str.end());

// 	ll pced=-1;

// 	for(int i=0;i<str.size();)
// 	{
// 	    while(str[i].ff<pced) i++;
// 	    int start=str[i].ff,gst=str[i].ss.length(),ind=i;
// 	    while(i<str.size() && str[i].ff==start)
// 	    {
// 	        if(str[i].ss.length()>gst)
// 	        {
// 	            gst=str[i].ss.length();
// 	            ind=i;
// 	        }
// 	        i++;
// 	    }

// 	    if(pced<start+str[ind].ss.length())
// 	    {
// 	    int j=0;
// 	    if(pced>start) j=pced;
// 	    for(;j<str[ind].ss.length();j++)
// 	    {
// 	        ans[j+start]=(str[ind].ss)[j];
// 	    }
// 	    pced=start+str[ind].ss.length()-1;
// 	    }

// 	}
// 	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<pair<int,string>> str;

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     str.pb(mp(a-1,sub));
	     len=max(len,a-1+sub.length());
	    }
	}

    sort(str.begin(),str.end());

	FOR(i,len) ans=ans+"a";

	ll pced=-1;

	for(int i=0;i<str.size();)
	{
	    int start=str[i].ff,gst=str[i].ss.length(),ind=i;
	    while(i<str.size() && str[i].ff==start)
	    {
	        if(str[i].ss.length()>gst)
	        {
	            gst=str[i].ss.length();
	            ind=i;
	        }
	        i++;
	    }

	    if(pced<start+str[ind].ss.length())
	    {
	    int j=0;
	    if(pced>start) j=pced;
	    for(;j<str[ind].ss.length();j++)
	    {
	        ans[j+start]=(str[ind].ss)[j];
	    }
	    pced=start+str[ind].ss.length()-1;
	    }

	}
	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<string> str[1000005];

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     a--;
	     if(str[a].size()==0) {str[a].pb(sub);len=max(len,a+sub.length());}
	     else
	     {
	      int len2=str[a][0].length(),curr=sub.length();
	      str[a][0]=(curr>len2)? sub:str[a][0];
	      len=max(len,a+str[a][0].length());
	     }
	    }
	}

	//cout<<len;

	FOR(i,len) ans=ans+"a";

// 	ll rec=0;

// 	for(int i=0;i<len;i++)
// 	{
// 	    if(str[i].size()==0) {continue;}

// 	    if(rec<=i+str[i][0].length()-1)
// 	    {
// 	    int j=rec-i;
// 	    for(;j<str[i][0].length();j++)
// 	    {
// 	     ans[i+j]=(str[i][0])[j];
// 	    }
// 	    rec=i+str[i][0].length();
// 	    }
// 	}

	ll pced=-1;

	for(int i=0;i<len;)
	{
	    if(str[i].size()==0) {i++;continue;}
	    if(pced<i+str[i][0].length())
	    {
	    int j=0;
	    if(pced>i) j=pced;
	    for(;j<str[i][0].length();j++)
	    {
	        ans[j+i]=(str[i][0])[j];
	    }
	    pced=i+str[i][0].length()-1;
	    }
	    i++;
	}

	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<pair<int,string>> str;

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     str.pb(mp(a-1,sub));
	     len=max(len,a-1+sub.length());
	    }
	}

    sort(str.begin(),str.end());

	FOR(i,len) ans=ans+"a";

	for(int i=0;i<str.size();)
	{
	    int start=str[i].ff,gst=str[i].ss.length(),ind=i;
	    while(i<str.size() && str[i].ff==start)
	    {
	        if(str[i].ss.length()>gst)
	        {
	            gst=str[i].ss.length();
	            ind=i;
	        }
	        i++;
	    }
	    for(int j=0;j<str[ind].ss.length();j++)
	    {
	        ans[j+start]=(str[ind].ss)[j];
	    }

	}
	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[2000005]={'?'};

	while(n--)
	{
	    cin>>s>>k;

	    while(k--)
	    {
	        cin>>start;
	        start--;
	        for(int i=0;i<s.length();i++)
	        {
	            ans[start+i]=s[i];
	        }
	    }
	}

	ll len=0;

	for(int i=1000004;i>=0;i--)
	{
	    if(ans[i]!='?') len=max(len,i);
	}

	for(int i=0;i<=len;i++)
	{
	    cout<<ans[i];
	}

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;
const int maxn=2e6+5;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

string s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	char ans[maxn]={};

	while(n--)
	{
	    cin>>s>>k;
	    int curr=s.size(),done=-curr;
	    while(k--)
	    {
	        scanf("%d",&start);
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}
	int i;
	for(i=maxn-1;!ans[i];)i--;
	for(int j=1;j<=i;j++) putchar(ans[j]?ans[j]:'a');

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[2000005]={'?'};

	for(int i=0;i<2000005;i++)
	{
	    ans[i]='?';
	}

	while(n--)
	{
	    cin>>s>>k;
	    int curr=s.length(),done=-curr;
	    while(k--)
	    {
	        cin>>start;
	        //start--;
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}

	ll len=0;

	for(len=100004;ans[len]=='?';) len--;

	for(int i=1;i<=len;i++)
	{
	    if(ans[i]=='?') cout<<"a";
	    else cout<<ans[i];
	}

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,sum=0;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b)?a:b;
}

int main() {
	// your code goes here

	cin>>n;

	string sub,ans;

	vector<pair<int,string>> str;

	int len=0;

	FOR(i,n)
	{
	    cin>>sub;
	    cin>>m;
	    FOR(j,m)
	    {
	     cin>>a;
	     str.pb(mp(a-1,sub));
	     len=max(len,a-1+sub.length());
	    }
	}

    sort(str.begin(),str.end());

	FOR(i,len) ans=ans+"a";

	ll pced=-1;

	for(int i=0;i<str.size();)
	{
	    while(str[i].ff<pced) i++;
	    int start=str[i].ff,gst=str[i].ss.length(),ind=i;
	    while(i<str.size() && str[i].ff==start)
	    {
	        if(str[i].ss.length()>gst)
	        {
	            gst=str[i].ss.length();
	            ind=i;
	        }
	        i++;
	    }

	    if(pced<start+str[ind].ss.length())
	    {
	    int j=0;
	    if(pced>start) j=pced;
	    for(;j<str[ind].ss.length();j++)
	    {
	        ans[j+start]=(str[ind].ss)[j];
	    }
	    pced=start+str[ind].ss.length()-1;
	    }

	}
	cout<<ans;

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[2000005]={'?'};

	for(int i=0;i<2000005;i++)
	{
	    ans[i]='?';
	}

	while(n--)
	{
	    cin>>s>>k;
	    int curr=s.length(),done=-curr;
	    while(k--)
	    {
	        cin>>start;
	        start--;
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}

	ll len=0;

	for(int i=1000004;i>=0;i--)
	{
	    if(ans[i]!='?') len=max(len,i);
	}

	for(int i=0;i<=len;i++)
	{
	    if(ans[i]=='?') cout<<"a";
	    else cout<<ans[i];
	}

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[1000005]={};

	while(n--)
	{
	    cin>>s>>k;
	    int curr=s.length(),done=-curr;
	    while(k--)
	    {
	        cin>>start;
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}
	int i;
	for(i=1000004;!ans[i];)i--;
	for(int j=1;j<=i;j++) putchar(ans[j]?ans[j]:'a');

	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#define ll int64_t
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,n) for(int i=0;i<n;i++)
//const int64_t INF = 1000000000000000000;

using namespace std;

ll arr[100005],freq[100005];
ll t,n,m,x,y,a,b,z,p,q,r,k,sum=0,start;
vector<ll> adj[100005],v;

set<ll> s;

ll max(ll a,ll b)
{
    return (a>b?a:b);
}

int main() {
	// your code goes here

	cin>>n;

	string s;
	char ans[1000005]={};

	while(n--)
	{
	    cin>>s>>k;
	    ll curr=s.length(),done=-curr;
	    while(k--)
	    {
	        scanf("%lld",&start);
	        for(int i=max(0,done+curr-start);i<curr;i++) ans[i+start]=s[i];
			done=start;
	    }
	}
	int i;
	for(i=1000004;!ans[i];)i--;
	for(int j=1;j<=i;j++) putchar(ans[j]?ans[j]:'a');

	return 0;
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[3000001];
int skip[3000001]={};
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<2000000;i++)
{a[i]='a';
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{if(skip[i])
i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))

int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
char a[1000001];
for(ll i=0;i<1000001;i++)
a[i]='a';
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
for(ll i=x;i<x+k;i++)
a[i]=s[i-x];
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll int
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[2000001];
int skip[2000001]={};
ll find(ll x)
{
if(skip[x]!=x)skip[x]=find(skip[x]);
return skip[x];
}
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<2000000;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{
i=find(i);
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[3000001];
int skip[3000001];
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<n;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))

int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
char a[1000001];
int skip[1000001];
for(ll i=0;i<1000001;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[1000001];
int skip[1000001];
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<1000001;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[3000001];
int skip[3000001]={};
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<n;i++)
{a[i]='a';
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{if(skip[i])
i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[3000001];
int skip[3000001];
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<3000001;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


/*************What doesn't kills you makes you stronger************************/
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define f(i,n) for( ll (i)= 0;(i)<(n);(i)++)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lp pair<ll,ll>
#define maxn 1000000
#define mp make_pair
#define mt make_tuple
#define M_H priority_queue<lp ,vector<lp >,greater<lp > >
//ll gcd(ll a ,ll b)  {return(a==0?b:gcd(b%a,a))
char a[10000001];
int skip[10000001];
int main()
{faster;
//freopen("input.txt","r",stdin);
ll n;
cin>>n;
ll pp=0;
for(ll i=0;i<10000001;i++)
{a[i]='a';
skip[i]=i;
}
while(n--)
{string s;
cin>>s;
ll k=s.size();
ll t,x;
cin>>t;
while(t--)
{cin>>x;
x--;
pp=max(x+k,pp);
ll i=x;
while(i<x+k)
{i=skip[i];
if(i>=x+k)
break;
a[i]=s[i-x];
skip[i]=x+k;
i++;
}
}
}
for(ll i=0;i<pp;i++)
{cout<<a[i];
//cout<<i;
}
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
set<pair<int,string> > v;
string t,ans="";
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>t>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(t.size()));
            v.insert({x-1,t});
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    //sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=i.second;
        int en=i.first-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i.first-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    for (int i=0;i<1000001;i++) {
        store[i]=-1;
    }
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            if((store[x-1]!=(-1)) && (T[store[x-1]].size()<T[i].size())) store[x-1]=i;
            else if (store[x-1]==(-1)) store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        int st=store[i];
        int en=i-1+(int)(T[st].size());
        if (en>mx) {
            for (int j=en,k=-1+T[st].size();j>max(mx,i-1);j--,k--) {
                ans[j]=T[st][k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<pair<int,int> > v;
string ans="",t;
vector<string> T;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back({x-1,i});
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[i.second];
        int en=i.first-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i.first-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    for (int i=0;i<=mx;i++) {
        store[i]=-1;
    }
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            if((store[x-1]!=(-1)) && (T[store[x-1]].size()<T[i].size())) store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[store[i]];
        int en=i-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    for (int i=0;i<1000001;i++) {
        store[i]=-1;
    }
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            if((store[x-1]!=(-1)) && (T[store[x-1]].size()<T[i].size())) store[x-1]=i;
            else if (store[x-1]==(-1)) store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += 'a';
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        int st=store[i];
        int en=i-1+(int)(T[st].size());
        if (en>mx) {
            for (int j=en,k=-1+T[st].size();j>max(mx,i-1);j--,k--) {
                ans[j]=T[st][k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<pair<int,string> > v;
string t,ans="";
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>t>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(t.size()));
            v.push_back({x-1,t});
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=i.second;
        int en=i.first-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i.first-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define lim 1000001
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,pos,max_pos=0,x;
    char ans[lim];
    //bool check[lim];
    string s;
    cin>>n;

    for (int i=0;i<lim;i++) {
        ans[i]='a';
        //check[i] = false;
    }

    while (n--) {
        cin>>s>>k;
        while (k--) {
            cin>>pos;
            x=s.size();
            if (k==0) {
                max_pos = max (max_pos,pos+x-1);
            }

            for (int i=0;i<x;i++) {
                ans[pos+i-1] = s[i];
                //check[pos+i-1] = true;
            }
         }
    }

    for (int i=0;i<max_pos;i++) {
        cout<<ans[i];
    }
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    for (int i=0;i<=mx;i++) {
        store[i]=-1;
    }
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            if((store[x-1]!=(-1)) && (T[store[x-1]].size()<T[i].size())) store[x-1]=i;
            else if (store[x-1]==(-1)) store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[store[i]];
        int en=i-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[store[i]];
        int en=i-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
set<pair<int,int> > v;
string T[1000005],ans="",t;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.insert({x-1,i});
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    //sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[i.second];
        int en=i.first-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i.first-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<ll,int> pi;
vector<int> v;
string ans="",t;
vector<string> T;
int store[1000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k,x,mx=-1;
    cin>>n;
    T.resize(n);
    for (int i=0;i<1000001;i++) {
        store[i]=-1;
    }
    cin.ignore();
    for (int i=0;i<n;i++) {
        cin>>T[i]>>k;
        while (k--) {
            cin>>x;
            mx=max(mx,x-2+(int)(T[i].size()));
            v.push_back(x-1);
            if((store[x-1]!=(-1)) && (T[store[x-1]].size()<T[i].size())) store[x-1]=i;
            else if (store[x-1]==(-1)) store[x-1]=i;
        }
    }
    for (int i=0;i<=mx;i++) {
        ans += "a";
    }
    sort(v.begin(),v.end());
    mx=-1;
    for (auto i:v) {
        t=T[store[i]];
        int en=i-1+(int)(t.size());
        if (en>mx) {
            for (int j=en,k=-1+t.size();j>max(mx,i-1);j--,k--) {
                ans[j]=t[k];
            }
            mx=en;
        }
    }
    cout<<ans;
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
 char m[2000110];
  string str;
int main()
{
 int n;
 cin>>n;
 int _max=0;
 while(n--)
 {
  cin>>str;
  int _n=str.length();
  int k;
  cin>>k;
      int le=0;
  for(int i=0;i<k;i++)
  {
    int t;
    cin>>t;
    t--;
    _max=max(_max,t+_n-1);
    for (int j=max(t,le);j<t+_n;j++)
    {
      m[j]=str[j-t];
    }
    le=t+_n;
  }
 }
  for(int i=0;i<_max;i++)
  {
   if(!m[i])
    m[i]='a';
  }
  cout<<m;

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  string str;
  scanf("%s",&str);
  long long _n=str.length();
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"a";
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  string str;
  cin>>str;
  long long _n=str.length();
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"a";
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  char str[1000010];
  scanf("%s",str);
  long long _n=strlen(str);
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        printf("%c",m[i]);
    else
        printf("a");
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
 char m[1000100];
int main()
{
 long long n;
 cin>>n;
 long long _max=0;
 while(n--)
 {
  string str;
  cin>>str;
  long long _n=str.length();
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"a";
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  char str[1000010];
  scanf("%s",str);
  long long _n=strlen(str);
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    long long le=0;
    l=0;
    _max=max(_max,t+_n-2);
    for (long long j=max(t-1,le);j<t+_n-1;j++)
    {
      m[j]=str[l];
     l++;
    }
    le=t+_n-1;
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        printf("%c",m[i]);
    else
        printf("a");
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  string str;
  cin>>str;
  long long _n=str.length();
  long long l=0;
  long long k;
  cin>>k;
  for(long long i=0;i<k;i++)
  {
    long long t;
    cin>>t;
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"z";
  }
  cout<<"\n";
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  char str[1000010];
  scanf("%s",str);
  long long _n=strlen(str);
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"a";
  }

}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  string str;
  cin>>str;
  long long _n=str.length();
  long long l=0;
  long long k;
  cin>>k;
  for(long long i=0;i<k;i++)
  {
    long long t;
    cin>>t;
    l=0;
    for (long long j=t-1;j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        cout<<m[i];
    else
        cout<<"a";
  }
  cout<<"\n";
}


#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define INF 1LL<<40
#define N 200100
int main()
{
 long long n;
 cin>>n;
 unordered_map<long long ,char>m;
 long long _max=0;
 while(n--)
 {
  char str[1000010];
  scanf("%s",str);
  long long _n=strlen(str);
  long long l=0;
  long long k;
  scanf("%lld",&k);
  for(long long i=0;i<k;i++)
  {
    long long t;
    scanf("%lld",&t);
    long long le=0;
    l=0;
    for (long long j=max(t-1,le);j<t+_n-1;j++)
    {
     if(!m[j])
     {
      m[j]=str[l];
     _max=max(_max,j);
     }
     l++;
    }
    le=t+_n-1;
  }
 }
  for(long long i=0;i<=_max;i++)
  {
    if(m[i])
        printf("%c",m[i]);
    else
        printf("a");
  }

}


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

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 2e6;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l)
		if (!cnt[i]) pc('a');
		else for(int b = cnt[i]+i,j=i; i < b && cnt[i + 1] > cnt[j]-i+j-1; i++)
				pc(str[j][b-i]);

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

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

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

map<int, pii> pos;
vector<string> strs;

int main() {
	FastRead;
	string s;
	int n, in, ind = 0, sz;
	scani(n);

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();
		strs.pb(s);

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			if (pos[ind-1].ff < sz)
				pos[ind-1] = mk(sz, i);
		}
	}

	int final = pos.rbegin()->ff;
	int j = 0, idx, edx;

	FOR(pos,i)
	{
		idx = i->ff;
		edx = idx + i->ss.ff;
		string st = strs[i->ss.ss];
		for (;j < idx; j++)
			pc('a');
		for (; j < edx; j++)
			pc(st[j - idx]);
	}

	return 0;
}


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

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

int main() {
	FastRead;
	int n,in,ind,last=-1; cin>>n;

	string s;
	map<int,string> m;

	Rep(i,n){ cin>>s>>in;
		Rep(j,in){ cin>>ind;
			if(m[ind].size()<s.size()) m[ind]=s;
		}
		last=max(last,ind);
	}

	for(int j=1;j<=last;) {
		if(!m[j].size()) {
			pc('a');j++;
		} else {
			string cur = m[j];
			int sz = cur.size();
			for(int i=0; sz && m[j].size()<=sz; sz--,j++,i++)
				pc(cur[i]);
		}
	}
	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

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

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

map<int, pii> pos;
vector<string> strs;

int main() {
	string s;
	int n, in, ind = 0, sz;
	scani(n);

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();
		strs.pb(s);

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			if (pos[ind-1].ff < sz)
				pos[ind-1] = mk(sz, i);
		}
	}

	int j = 0, idx, edx;
	FOR(pos,i)
	{
		idx = i->ff;
		edx = idx + i->ss.ff;
		string st = strs[i->ss.ss];
		for (; j < idx; j++)
			pc('a');
		for (; j < edx; j++)
			pc(st[j - idx]);
	}

	return 0;
}


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

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 1e6 + 7;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l)
	{
		if (!cnt[i])
			pc('a');
		else
			for (int j = 0; j < cnt[i]; j++) {
				pc(str[i][j]);
				if (cnt[j + i + 1] > cnt[i] - j - 1) {
					i += j;
					break;
				}
			}
	}

	return 0;
}


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

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 1e7 + 7;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l)
	{
		if (!cnt[i])
			pc('a');
		else
			for (int j = 0; j < cnt[i]; j++) {
				pc(str[i][j]);
				if (cnt[j + i + 1] > cnt[i] - j - 1) {
					i += j;
					break;
				}
			}
	}

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

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

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

const int N =1e6+7;
char out[4*N];
int jt[4*N];

int main() {
	string s;
	int n, idx=0,edx=-1,in,ind, sz, last=-1;
	scani(n);
	memset(out,'a',sizeof out);
	Rep(i,N) jt[i]=i+1;

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			idx=--ind;
			edx=idx+sz;
			for(;idx<edx;idx=jt[idx]) {
				out[idx]=s[idx-ind];
				if(idx)jt[idx-1]=edx;
			}
		}
		last=max(last,edx);
	}

	Rep(i,last)
		pc(out[i]);
	pc(endl);

	return 0;
}