#include <bits/stdc++.h>
using namespace std;
vector<int> graph[(int)27];
int used[27];
int color[27];
bool find_cycles(int v) {
  color[v] = 1;
  for (auto x : graph[v]) {
    if (color[x] == 0) {
      if (find_cycles(x)) return true;
    } else if (color[x] == 1) {
      return true;
    }
  }
  color[v] = 2;
  return false;
}
void dfs(int x, vector<int> &tsort) {
  used[x] = 1;
  for (auto to : graph[x]) {
    if (!used[to]) dfs(to, tsort);
  }
  tsort.push_back(x);
}
char ss[101];
int main() {
  vector<int> cnt(27, 0);
  int n, k;
  scanf("%d%d", &n, &k);
  vector<pair<int, vector<string>>> input;
  for (int i = 0; i < n; i++) {
    vector<string> str(k, "");
    int x;
    scanf("%d", &x);
    for (auto &j : str) {
      scanf("%s", ss);
      j = ss;
      for (auto c : j) cnt[c - 'a']++;
    }
    input.push_back({x, str});
  }
  sort(input.begin(), input.end());
  vector<string> a;
  for (auto &i : input)
    for (auto &j : i.second) a.push_back(j);
  for (int i = 1; i < a.size(); i++) {
    string p = a[i - 1];
    string x = a[i];
    int j = 0;
    while (j < min(p.size(), x.size()) && p[j] == x[j]) ++j;
    if (j >= min(p.size(), x.size())) {
      if (p.size() > x.size()) {
        cout << "IMPOSSIBLE\n";
        return 0;
      }
      continue;
    }
    graph[p[j] - 'a'].push_back(x[j] - 'a');
  }
  vector<vector<int>> alphabet;
  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < 27; j++) color[j] = 0;
    if (find_cycles(i)) {
      cout << "IMPOSSIBLE" << '\n';
      return 0;
    }
    vector<int> temp;
    if (!used[i] && cnt[i]) {
      dfs(i, temp);
      reverse(temp.begin(), temp.end());
      alphabet.push_back(temp);
    }
  }
  reverse(alphabet.begin(), alphabet.end());
  for (auto i : alphabet)
    for (auto ii : i) cout << char(ii + 'a');
  cout << '\n';
}
