#include <bits/stdc++.h>
using namespace std;
vector<long long int> lis[27];
long long int flag, present[27], visited[27];
stack<long long int> lyis;
void dfs(long long int x, long long int y) {
  if (flag) return;
  visited[x] = 1;
  for (int i = 0; i < lis[x].size(); i++) {
    if (visited[lis[x][i]] == 1) flag = 1;
    if (!visited[lis[x][i]]) dfs(lis[x][i], y);
    visited[lis[x][i]] = 2;
  }
  lyis.push(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, num, siz = 0;
  cin >> n >> k;
  vector<pair<long long int, vector<string> > > v;
  string t;
  for (int i = 0; i < n; i++) {
    cin >> num;
    vector<string> vec;
    for (int j = 0; j < k; j++) {
      cin >> t;
      vec.push_back(t);
    }
    v.push_back(make_pair(num, vec));
  }
  sort(v.begin(), v.end());
  string s[n * k];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < v[i].second.size(); j++) {
      s[siz] = v[i].second[j], siz++;
      for (int l = 0; l < v[i].second[j].length(); l++)
        present[v[i].second[j][l] - 'a'] = 1;
    }
  }
  for (int i = 0; i < n * k - 1; i++) {
    long long int p = s[i].length(), q = s[i + 1].length(), count = 0;
    for (int j = 0; j < min(p, q); j++) {
      if (s[i][j] == s[i + 1][j])
        count++;
      else {
        lis[s[i][j] - 'a'].push_back(s[i + 1][j] - 'a');
        break;
      }
    }
    if (count == min(p, q) && p > q) {
      flag = 1;
      break;
    }
  }
  for (int i = 0; i < 26; i++) {
    if (!visited[i] && present[i]) {
      dfs(i, i);
      visited[i] = 2;
    }
  }
  if (flag) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  while (lyis.size()) {
    cout << (char(lyis.top() + 'a'));
    lyis.pop();
  }
  return 0;
}
