#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<long long> graph[26];
bool check = false;
void make_edge(string &a, string &b) {
  bool check2 = false;
  for (long long i = 0; i < min(a.length(), b.length()); i++) {
    if (a[i] != b[i]) {
      check2 = true;
      graph[a[i] - 'a'].push_back(b[i] - 'a');
      break;
    }
  }
  if (!check2 && a.length() > b.length()) check = true;
  return;
}
void dfs(long long par, stack<long long> &st, bool visited[]) {
  visited[par] = true;
  for (auto &it : graph[par])
    if (!visited[it]) dfs(it, st, visited);
  st.push(par);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<pair<string, string>> pg(n);
  bool exist[26];
  for (long long i = 0; i < 26; i++) exist[i] = false;
  for (long long i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    string prev;
    cin >> prev;
    for (long long i = 0; i < prev.length(); i++) exist[prev[i] - 'a'] = true;
    string next;
    pg[temp].first = prev;
    for (long long j = 1; j < k; j++) {
      cin >> next;
      for (long long i = 0; i < next.length(); i++) exist[next[i] - 'a'] = true;
      make_edge(prev, next);
      prev = next;
    }
    pg[temp].second = prev;
  }
  if (n == 1 && k == 1) {
    for (long long i = 0; i < 26; i++)
      if (exist[i]) cout << char(i + 'a');
    return;
  }
  for (long long i = 0; i < n - 1; i++) {
    string one = pg[i].second;
    string next = pg[i + 1].first;
    make_edge(one, next);
  }
  bool visited[30];
  for (long long i = 0; i < 30; i++) visited[i] = false;
  stack<long long> st;
  for (long long i = 0; i < 26; i++) {
    if (!visited[i] && exist[i]) {
      dfs(i, st, visited);
    }
  }
  long long ind[26];
  long long alpha[27];
  long long ptr = 1;
  while (!st.empty()) {
    long long top = st.top();
    st.pop();
    alpha[ptr] = top;
    ind[top] = ptr;
    ptr++;
  }
  for (long long i = 0; i < 26; i++) {
    for (auto it : graph[i]) {
      if (ind[it] < ind[i]) {
        check = true;
        break;
      }
    }
    if (check) break;
  }
  if (check) {
    cout << "IMPOSSIBLE";
    return;
  }
  for (long long i = 1; i < ptr; i++) {
    cout << char(alpha[i] + 'a');
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
}
