#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
int c[26] = {};
vector<int> g[26];
int in[26];
void check(string prev, string cur) {
  if (prev.size() > cur.size() && prev.substr(0, cur.size()) == cur) {
    cout << "IMPOSSIBLE\n";
    exit(0);
  }
  for (int i = 0; i < min(prev.size(), cur.size()); i++) {
    if (prev[i] != cur[i]) {
      g[prev[i] - 'a'].push_back(cur[i] - 'a');
      in[cur[i] - 'a']++;
      return;
    }
  }
}
void topo() {
  queue<int> q;
  vector<int> ans;
  for (int i = 0; i < 26; i++) {
    if (!in[i]) {
      q.push(i);
    }
  }
  while (q.size()) {
    auto now = q.front();
    q.pop();
    ans.push_back(now);
    for (auto &i : g[now]) {
      in[i]--;
      if (!in[i]) {
        q.push(i);
      }
    }
  }
  if (ans.size() != 26) {
    cout << "IMPOSSIBLE\n";
    exit(0);
  }
  for (auto &i : ans) {
    if (!c[i]) continue;
    cout << char('a' + i);
  }
  cout << '\n';
}
void go() {
  int n, k;
  cin >> n >> k;
  vector<pair<pair<int, int>, string>> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < k; j++) {
      string s;
      cin >> s;
      for (auto &k : s) {
        c[k - 'a'] = 1;
      }
      v.push_back({{x, j}, s});
    }
  }
  sort(v.begin(), v.end());
  for (int i = 1; i < v.size(); i++) {
    check(v[i - 1].second, v[i].second);
  }
  topo();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int c = 0;
  int t;
  if (!c) {
    t = 1;
  } else {
    cin >> t;
  }
  while (t--) {
    go();
  }
}
