#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long n;
  cin >> n;
  vector<string> vs;
  vector<int> vi;
  for (int i = 0; i < n; ++i) {
    string s;
    int k;
    cin >> s >> k;
    vs.push_back(s);
    for (int j = 0; j < k; ++j) {
      int x;
      cin >> x;
      --x;
      if (vi.size() <= x) {
        vi.resize(x + 1, -1);
      }
      if (vi[x] == -1 || vs[vi[x]].size() < s.size()) vi[x] = i;
    }
  }
  int si = -1;
  int ind = -1;
  int len = 0;
  for (int i = 0; i < vi.size(); ++i) {
    if (si != -1) {
      --len;
      ++ind;
      if (len == 0) {
        si = -1;
        ind = -1;
      }
    }
    if (vi[i] != -1) {
      if (si == -1) {
        si = vi[i];
        len = vs[si].size();
        ind = 0;
      } else if (len < vs[vi[i]].size()) {
        si = vi[i];
        len = vs[si].size();
        ind = 0;
      }
    }
    if (si != -1) {
      cout << vs[si][ind];
    } else {
      cout << 'a';
    }
  }
  if (si != -1) {
    --len;
    for (; len > 0; --len) {
      ++ind;
      cout << vs[si][ind];
    }
  }
  cout << endl;
  return 0;
}
