#include <bits/stdc++.h>
using namespace std;
long long int pow_mod(long long int a, long long int b) {
  long long int res = 1;
  while (b != 0) {
    if (b & 1) {
      res = (res * a) % 998244353;
    }
    a = (a * a) % 998244353;
    b /= 2;
  }
  return res;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int p[n];
  long long int is[26] = {0};
  string s[n][k];
  for (long long int i = 0; i < n; i++) {
    cin >> p[i];
    for (long long int j = 0; j < k; j++) {
      cin >> s[p[i]][j];
      for (long long int x = 0; x < s[p[i]][j].size(); x++) {
        is[(long long int)(s[p[i]][j][x] - 'a')] = 1;
      }
    }
  }
  vector<string> v;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < k; j++) {
      v.push_back(s[i][j]);
    }
  }
  vector<long long int> adj[27];
  long long int sz = v.size();
  long long int indeg[26] = {0};
  map<pair<long long int, long long int>, long long int> mp;
  for (long long int i = 1; i < sz; i++) {
    long long int id = -1;
    for (long long int j = 0;
         j < min((long long int)v[i].size(), (long long int)v[i - 1].size());
         j++) {
      if (v[i][j] != v[i - 1][j]) {
        long long int x = (long long int)(v[i][j] - 'a');
        long long int y = (long long int)(v[i - 1][j] - 'a');
        if (mp[{y, x}]) {
          id = (long long int)1e18;
          break;
        }
        adj[y].push_back(x);
        mp[{y, x}]++;
        indeg[x]++;
        id = j;
        break;
      }
    }
    if (id == (long long int)1e18) continue;
    if (id == -1) {
      if (v[i].size() < v[i - 1].size()) {
        cout << "IMPOSSIBLE\n";
        return;
      }
    }
  }
  vector<long long int> res;
  vector<long long int> start;
  for (long long int i = 0; i < 26; i++) {
    if (is[i] && indeg[i] == 0) start.push_back(i);
  }
  bool mark[26];
  memset(mark, false, sizeof(mark));
  string ans;
  long long int tot = 0;
  set<long long int> st;
  for (long long int i = 0; i < 26; i++) {
    if (indeg[i] == 0 && is[i]) st.insert(i);
  }
  while (!st.empty()) {
    long long int x = *st.begin();
    res.push_back(x);
    mark[x] = true;
    for (auto node : adj[x]) {
      if (mark[node]) continue;
      indeg[node]--;
      if (indeg[node] == 0) st.insert(node);
    }
    st.erase(x);
  }
  for (long long int i = 0; i < 26; i++)
    if (is[i]) ++tot;
  for (long long int i = 0; i < res.size(); i++) ans += (char)(res[i] + 'a');
  if (ans.size() != tot) {
    cout << "IMPOSSIBLE\n";
    return;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) solve();
  return 0;
}
