#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <string>#include <vector>#include <stack>#include <bitset>#include <cstdlib>#include <cmath>#include <set>#include <list>#include <deque>#include <map>#include <queue>usingnamespacestd;
typedeflonglong ll;
#define maxn 1000010char s[maxn];
int ans[maxn];
char anss[maxn];
struct node
{
int l;
int r;
int ix;
}dic[maxn];
bool cmp (node a,node b){
if (a.l==b.l ){
return a.r > b.r;
}
return a.l < b.l;
}
vector <int> g[maxn];
int main (){
int n;
int i;
int t= 0;
scanf ("%d",&n);
for (i=1;i<=n;i++){
scanf("%s",s);
int j;
int ll =strlen (s);
for (j=0;j<strlen(s);j++){
g[i].push_back (s[j]-'a');
}
int d;
scanf ("%d",&d);
for (j=1;j<=d;j++){
int a;
scanf ("%d",&a);
dic[++t].l = a;
dic[t].r = a + ll-1;
dic[t].ix = i;
}
}
//for (i=1;i<=t;i++){// for (int j=0;j<g[i].size();j++)// printf("%d",g[i][j]);// printf("\n");//}
sort (dic+1,dic+1+t,cmp);
//for (i=1;i<=t;i++){// printf("%d %d %d\n",dic[i].l,dic[i].r,dic[i].ix);// }int tmp = 0;
int j;
int right = 0;
for (i=1;i<=t;i++){
int left = dic[i].l;
int d = dic[i].ix;
if (dic[i].r >tmp){
right = max (right,dic[i].r);
int begin = left;
if (left >tmp){
for (j=0;j<g[d].size();j++){
ans[begin++] = g[d][j];
// printf("%d",ans[begin-1]);
}
}
else {
int begin = tmp+1;
int le = tmp+1-left;
for (j= le;j<g[d].size();j++){
ans[begin++]=g[d][j];
}
}
tmp = dic[i].r;
}
}
//puts ("");for (i=1;i<=right;i++){
if (!ans[i]) printf("a");
else{
printf("%c",ans[i]+'a');
}
}
printf("\n");
}