#include <bits/stdc++.h>
using namespace std;
template <class TPL>
void KAN(TPL A) {
  std ::cerr << std ::endl
             << "Element Number = " << A.size() << std ::endl
             << "< ";
  for (auto it : A) std ::cerr << it << ", ";
  std ::cerr << ">" << std ::endl << std ::endl;
}
namespace Fast_IO {
const int MAXL((1 << 18) + 1);
int iof, iotp;
char ioif[MAXL], *ioiS, *ioiT, ioof[MAXL],
    *iooS = ioof, *iooT = ioof + MAXL - 1, ioc, iost[55];
char Getchar() {
  if (ioiS == ioiT) {
    ioiS = ioif;
    ioiT = ioiS + fread(ioif, 1, MAXL, stdin);
    return (ioiS == ioiT ? EOF : *ioiS++);
  } else
    return (*ioiS++);
}
void Write() {
  fwrite(ioof, 1, iooS - ioof, stdout);
  iooS = ioof;
}
void Putchar(char x) {
  *iooS++ = x;
  if (iooS == iooT) Write();
}
inline int read() {
  int x = 0;
  for (iof = 1, ioc = Getchar(); (ioc < '0' || ioc > '9') && ioc != EOF;)
    iof = ioc == '-' ? -1 : 1, ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (x = 0; ioc <= '9' && ioc >= '0'; ioc = Getchar())
    x = (x << 3) + (x << 1) + (ioc ^ 48);
  return x * iof;
}
inline long long read_ll() {
  long long x = 0;
  for (iof = 1, ioc = Getchar(); (ioc < '0' || ioc > '9') && ioc != EOF;)
    iof = ioc == '-' ? -1 : 1, ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (x = 0; ioc <= '9' && ioc >= '0'; ioc = Getchar())
    x = (x << 3) + (x << 1) + (ioc ^ 48);
  return x * iof;
}
template <class Int>
void Print(Int x, char ch = '\0') {
  if (!x) Putchar('0');
  if (x < 0) Putchar('-'), x = -x;
  while (x) iost[++iotp] = x % 10 + '0', x /= 10;
  while (iotp) Putchar(iost[iotp--]);
  if (ch) Putchar(ch);
}
void Getstr(char *s, int &l) {
  for (ioc = Getchar(); ioc == ' ' || ioc == '\n' || ioc == '\t';)
    ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (l = 0; !(ioc == ' ' || ioc == '\n' || ioc == '\t' || ioc == EOF);
       ioc = Getchar())
    s[l++] = ioc;
  s[l] = 0;
}
void Putstr(const char *s) {
  for (int i = 0, n = strlen(s); i < n; ++i) Putchar(s[i]);
}
}  // namespace Fast_IO
using namespace Fast_IO;
const int MAX = 1e3 + 50;
const long long MOD = 998244353;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-7;
long long qpow(long long a, long long n) {
  long long res = 1LL;
  while (n) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
long long qpow(long long a, long long n, long long p) {
  a %= p;
  long long res = 1LL;
  while (n) {
    if (n & 1) res = res * a % p;
    a = a * a % p;
    n >>= 1;
  }
  return res;
}
long long npow(long long a, long long n) {
  long long res = 1LL;
  while (n) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
    if (res < 0 || a < 0) return 0;
  }
  return res;
}
long long inv(long long a) { return qpow(a, MOD - 2); }
long long inv(long long a, long long p) { return qpow(a, p - 2, p); }
int n, k;
struct node {
  int page, pos;
  string ss;
  bool operator<(const node &ND) const {
    if (page != ND.page) return page < ND.page;
    return pos < ND.pos;
  }
} aa[MAX * MAX];
bool to[30][30];
bool app[30];
int deg[30];
queue<int> Q;
queue<char> ANS;
void topo() {
  int cnt = 0;
  for (int i = 0; i < 26; ++i) {
    if (app[i] && !deg[i]) Q.push(i);
    if (app[i]) cnt++;
  }
  while (Q.size()) {
    int x = Q.front();
    Q.pop();
    char t = 'a' + x;
    ANS.push(t);
    for (int i = 0; i < 26; ++i) {
      if (to[x][i] && deg[i]) {
        deg[i]--;
        if (!deg[i]) Q.push(i);
      }
    }
  }
  if (ANS.size() != cnt)
    puts("IMPOSSIBLE");
  else {
    while (!ANS.empty()) {
      printf("%c", ANS.front());
      ANS.pop();
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int tot = 0;
  cin >> n >> k;
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    int pg;
    cin >> pg;
    for (int j = 0; j < k; ++j) {
      aa[tot].pos = j;
      aa[tot].page = pg;
      cin >> aa[tot].ss;
      for (int t = 0; t < aa[tot].ss.size(); ++t)
        app[aa[tot].ss[t] - 'a'] = true;
      tot++;
    }
  }
  sort(aa, aa + tot);
  for (int i = 0; i + 1 < tot; ++i) {
    int L1 = aa[i].ss.size();
    int L2 = aa[i + 1].ss.size();
    bool same = true;
    for (int j = 0; j < min(L1, L2); ++j) {
      int t1 = aa[i].ss[j] - 'a';
      int t2 = aa[i + 1].ss[j] - 'a';
      if (t1 == t2) continue;
      if (!to[t1][t2]) deg[t2]++;
      to[t1][t2] = true;
      same = false;
      break;
    }
    if (same && L1 > L2) {
      puts("IMPOSSIBLE");
      return 0;
    }
  }
  topo();
  return 0;
}
