#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
namespace ywy {
char str[1010][1010][103];
int len[1010][1010], num[1010], pos[1010], deg[26], que[100], has[100];
vector<int> vec[30];
inline int get(char *s) {
  int n = 0;
  char c;
  while ((c = getchar()) || 23333)
    if (c >= 'a' && c <= 'z') break;
  s[n] = c;
  n++;
  has[c - 'a'] = 1;
  while ((c = getchar()) || 23333) {
    if (c >= 'a' && c <= 'z') {
      s[n] = c;
      has[c - 'a'] = 1;
      n++;
    } else
      return (n);
  }
}
inline void did(int y1, int x1, int y2, int x2) {
  int ln = min(len[y1][x1], len[y2][x2]);
  for (register int i = 0; i < ln; i++) {
    if (str[y1][x1][i] != str[y2][x2][i]) {
      vec[str[y1][x1][i] - 'a'].push_back(str[y2][x2][i] - 'a');
      deg[str[y2][x2][i] - 'a']++;
      return;
    }
  }
  if (len[y1][x1] > len[y2][x2]) {
    printf("IMPOSSIBLE\n");
    exit(0);
  }
}
void ywymain() {
  int n, k;
  cin >> n >> k;
  for (register int i = 0; i < n; i++) {
    cin >> num[i];
    pos[num[i]] = i;
    for (register int j = 0; j < k; j++) len[i][j] = get(str[i][j]);
  }
  int cnt = 0;
  for (register int i = 0; i < 26; i++) cnt += has[i];
  for (register int i = 0; i < n; i++) {
    for (register int j = 0; j < k - 1; j++) did(i, j, i, j + 1);
    if (num[i] != n - 1) did(i, k - 1, pos[num[i] + 1], 0);
  }
  int head = 0, tail = 0;
  for (register int i = 0; i < 26; i++) {
    if (deg[i] == 0 && has[i]) que[tail] = i, tail++;
  }
  while (head < tail) {
    int me = que[head];
    head++;
    for (register int i = 0; i < vec[me].size(); i++) {
      deg[vec[me][i]]--;
      if (!deg[vec[me][i]]) que[tail] = vec[me][i], tail++;
    }
  }
  if (tail != cnt) {
    printf("IMPOSSIBLE\n");
    return;
  }
  for (register int i = 0; i < tail; i++) putchar(que[i] + 'a');
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return (0);
}
