#include <bits/stdc++.h>
using namespace std;
bool rev(long long x, long long y) { return x > y; }
void input_arr(long long a[], long long n) {
  for (long long i = 0; i < n; i += 1) cin >> a[i];
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return a.second < b.second;
}
bool sortinrev(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.first > b.first);
}
void print_vec(vector<long long> &v) {
  for (auto i : v) cout << i << " ";
  cout << '\n';
}
bool sortinrevbysec(const pair<long long, long long> &a,
                    const pair<long long, long long> &b) {
  return (a.second > b.second);
}
void print_arr(long long a[], long long n) {
  for (long long i = 0; i < n; i += 1) cout << a[i] << " ";
  cout << '\n';
}
template <typename... T>
void input(T &...args) {
  ((cin >> args), ...);
}
template <typename... T>
void print(T &&...args) {
  ((cout << args << '\n'), ...);
}
template <typename... T>
void deb(T &&...args) {
  cout << "~~ ";
  ((cout << args << " "), ...);
  cout << '\n';
}
vector<string> vs;
map<pair<char, char>, long long> mpp;
string s, t;
vector<long long> visited(26, 0);
vector<vector<long long>> vv_(26);
vector<long long> v_;
void topo_sort(long long x) {
  visited[x]++;
  for (auto vbn : vv_[x]) {
    if (visited[vbn] == 0) {
      topo_sort(vbn);
    }
  }
  v_.push_back(x);
}
void stand8th() {
  long long n, k, p;
  input(n, k);
  for (long long i = 0; i < n * k; i += 1) vs.push_back("#");
  for (long long i = 0; i < n; i += 1) {
    input(p);
    for (long long j = 0; j < k; j += 1) input(vs[p * k + j]);
  }
  map<char, long long> mapp;
  for (auto vbn : vs) {
    for (long long i = 0; i < (long long)(vbn.size()); i += 1) mapp[vbn[i]]++;
  }
  for (long long g = 1; g < (long long)(vs.size()); g += 1) {
    s = vs[g - 1];
    t = vs[g];
    long long fll = 0;
    for (long long i = 0; i < min((long long)(s.size()), (long long)(t.size()));
         i += 1) {
      if (s[i] != t[i]) {
        vv_[(long long)(s[i] - 'a')].push_back((long long)(t[i] - 'a'));
        mpp[{s[i], t[i]}]++;
        fll++;
        break;
      }
    }
    if (fll == 0 && (long long)(s.size()) > (long long)(t.size())) {
      print("IMPOSSIBLE");
      return;
    }
  }
  for (long long i = 0; i < 26; i += 1) {
    for (long long j = i + 1; j < 26; j += 1) {
      char c = 'a' + i, d = 'a' + j;
      if (mpp[{c, d}] > 0 && mpp[{d, c}] > 0) {
        print("IMPOSSIBLE");
        return;
      }
    }
  }
  vector<long long> rtt;
  for (long long i = 0; i < 26; i += 1) {
    long long fl = 0;
    char c = 'a' + i;
    for (auto vbn : mpp) {
      if (vbn.second > 0 && vbn.first.second == c) {
        fl++;
        break;
      }
    }
    if (fl == 0) rtt.push_back(i);
  }
  for (auto vbn : rtt) {
    if (visited[vbn] == 0) {
      topo_sort(vbn);
    }
  }
  reverse((v_).begin(), (v_).end());
  string ans;
  for (auto vbn : v_) {
    ans += (char)('a' + vbn);
  }
  if ((long long)(ans.size()) != 26) {
    print("IMPOSSIBLE");
    return;
  }
  for (long long i = 0; i < (long long)(ans.size()); i += 1) {
    for (long long j = i + 1; j < (long long)(ans.size()); j += 1) {
      if (mpp[{ans[j], ans[i]}] > 0) {
        print("IMPOSSIBLE");
        return;
      }
    }
  }
  for (long long i = 0; i < (long long)(ans.size()); i += 1) {
    if (mapp[ans[i]] > 0) cout << ans[i];
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tin = 1;
  while (tin--) {
    stand8th();
  }
  return 0;
}
