#include <bits/stdc++.h>
using namespace std;
long long n, k, i, j, first, sss[5000005];
vector<pair<long long, long long> > v;
string ss, s[1000005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= 5e6; ++i) ss.push_back('a');
  for (i = 1; i <= n; ++i) {
    cin >> s[i];
    cin >> k;
    for (j = 0; j < k; ++j) {
      cin >> first;
      if (s[sss[first - 1]].length() < s[i].length()) {
        sss[first - 1] = i;
        v.push_back({first - 1, first - 1 + s[i].length() - 1});
      }
    }
  }
  long long cur = 0;
  sort(v.begin(), v.end());
  for (i = 0; i < v.size(); ++i) {
    cur = max(cur, v[i].first);
    while (cur <= v[i].second) {
      ss[cur] = s[sss[v[i].first]][cur - v[i].first];
      cur++;
    }
  }
  for (i = 0; i < cur; ++i) cout << ss[i];
  return 0;
}
