#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 1000 * 1000 + 10;
const long long N2 = 70;
const long double PI = 3.141592653589793;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p = LLONG_MAX) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
vector<long long> g[26];
long long pos[26];
vector<long long> order;
string s[N + 1];
bool toposort(long long n) {
  order.clear();
  queue<long long> q;
  vector<long long> indeg(n + 1, 0);
  for (long long i = 0; i < n; i++)
    for (auto &it : g[i]) indeg[it]++;
  for (long long i = 0; i < n; i++) {
    if (!indeg[i]) q.push(i);
  }
  long long idx = 0;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    order.push_back(u);
    idx++;
    pos[u] = idx;
    for (auto &v : g[u]) {
      indeg[v]--;
      if (!indeg[v]) q.push(v);
    }
  }
  return (order.size() == n);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long c[26] = {0};
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    for (long long j = 0; j < k; j++) {
      cin >> s[k * x + j];
      for (auto y : s[k * x + j]) c[y - 'a']++;
    }
  }
  long long si = n * k;
  for (long long i = 0; i < si - 1; i++) {
    long long f = 0;
    for (long long j = 0; j < min(s[i].size(), s[i + 1].size()); j++) {
      if (s[i][j] != s[i + 1][j]) {
        g[s[i][j] - 'a'].push_back(s[i + 1][j] - 'a');
        f = 1;
        break;
      }
    }
    if (!f) {
      if (s[i].size() > s[i + 1].size()) {
        cout << "IMPOSSIBLE"
             << "\n";
        return 0;
      }
    }
  }
  bool ok = toposort(26);
  if (!ok)
    cout << "IMPOSSIBLE";
  else {
    for (auto y : order) {
      if (c[y]) {
        char f = y + 'a';
        cout << f;
      }
    }
  }
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
  return 0;
}
