#include <bits/stdc++.h>
using namespace std;
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int binary_search(std::vector<int>& s, std::vector<int>& height, int first,
                  int last, int x) {
  while (last > first) {
    int mid = first + (last - first) / 2;
    if (height[s[mid]] > x)
      last = mid;
    else
      first = mid + 1;
  }
  return first;
}
int LongestIncreasingSubsequenceLength(std::vector<int>& height) {
  if (height.size() == 0) return 0;
  int n = height.size();
  int i, k, index;
  std::vector<int> s(height.size() + 1, 0);
  index = 1;
  s[1] = 0;
  for (i = 1; i < n; i++) {
    if (height[i] >= height[s[index]]) {
      index++;
      s[index] = i;
    } else {
      k = binary_search(s, height, 1, index, height[i]);
      if (height[s[k]] >= height[i]) {
        s[k] = i;
      }
    }
  }
  return index;
}
void solve() {
  int n, k;
  cin >> n >> k;
  string s[n][k];
  vector<string> lol;
  int A[26][26] = {0};
  int visit[26] = {0};
  for (int i = 0; i < 26; i++) {
    visit[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < k; j++) {
      cin >> s[a][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      lol.push_back(s[i][j]);
    }
  }
  int y = lol.size();
  int count = 0, flag = 1;
  for (int i = 0; i < y - 1; i++) {
    int a = lol[i].size();
    int b = lol[i + 1].size();
    for (int j = 0; j < min(a, b); j++) {
      if (lol[i][j] != lol[i + 1][j]) {
        A[lol[i][j] - 'a'][lol[i + 1][j] - 'a'] = 1;
        break;
      }
      if (j == min(a, b) - 1 && a > b) {
        flag = 0;
      }
    }
  }
  for (int i = 0; i < y; i++) {
    int a = lol[i].size();
    for (int j = 0; j < a; j++) {
      visit[lol[i][j] - 'a'] = 0;
    }
  }
  for (int i = 0; i < 26; i++) {
    count += visit[i];
  }
  string f = "";
  if (flag == 0) {
    cout << "IMPOSSIBLE";
    return;
  }
  for (int i = 0; i < 26 - count; i++) {
    int b = -1;
    for (int j = 0; j < 26; j++) {
      int val = 0;
      for (int k = 0; k < 26; k++) {
        val += A[j][k];
      }
      if (val == 0 && visit[j] == 0) {
        b = j;
        break;
      }
    }
    if (b == -1) {
      cout << "IMPOSSIBLE";
      return;
    }
    visit[b] = 1;
    for (int k = 0; k < 26; k++) {
      A[k][b] = 0;
    }
    if (b != -1) f = (char)('a' + b) + f;
  }
  cout << f;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
