Problem: While exploring the old caves, researchers found a book, or more precisely, a stash of mixed pages from a book. Luckily, all of the original pages are present and each page contains its number. Therefore, the researchers can reconstruct the book.

After taking a deeper look into the contents of these pages, linguists think that this may be some kind of dictionary. What's interesting is that this ancient civilization used an alphabet which is a subset of the English alphabet, however, the order of these letters in the alphabet is not like the one in the English language.

Given the contents of pages that researchers have found, your task is to reconstruct the alphabet of this ancient civilization using the provided pages from the dictionary.

Input

First-line contains two integers: n and k (1 ≤ n, k ≤ 10^3) — the number of pages that scientists have found and the number of words present at each page. Following n groups contain a line with a single integer p_i (0 ≤ n < 10^3) — the number of i-th page, as well as k lines, each line containing one of the strings (up to 100 characters) written on the page numbered p_i.

Output

Output a string representing the reconstructed alphabet of this ancient civilization. If the book found is not a dictionary, output "IMPOSSIBLE" without quotes. In case there are multiple solutions, output any of them.

Example

Input


3 3
2
b
b
bbac
0
a
aca
acba
1
ab
c
ccb


Output


acb

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
namespace P_TEMPLATE {
class fastin {
 private:
  int _ch, _f;

 public:
  inline fastin& operator>>(char& c) {
    c = getchar();
    return *this;
  }
  template <typename _Tp>
  inline fastin& operator>>(_Tp& _x) {
    _x = 0;
    while (!isdigit(_ch)) _f |= (_ch == 45), _ch = getchar();
    while (isdigit(_ch))
      _x = (_x << 1) + (_x << 3) + (_ch ^ 48), _ch = getchar();
    _f && (_x = -_x, _f = 0);
    return *this;
  }
  fastin() { _ch = _f = 0; }
} fin;
class fastout {
 private:
  int _num[32], _head;

 public:
  inline fastout& operator<<(char c) {
    putchar(c);
    return *this;
  }
  template <typename _Tp>
  inline fastout& operator<<(_Tp _x) {
    _Tp _k;
    if (_x == 0) {
      putchar('0');
      return *this;
    }
    if (_x < 0) putchar('-'), _x = -_x;
    while (_x > 0)
      _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,
      _x = _k;
    while (_head > 0) putchar(_num[_head]), --_head;
    return *this;
  }
  fastout() { _head = 0; }
} fout;
inline void P_INIT() {}
}  // namespace P_TEMPLATE
using namespace P_TEMPLATE;
using namespace std;
const int maxn = 1000004, maxm = 104;
const int mod = 1000000007, inf = 1201201201;
int n, k, p;
char s[maxn][maxm];
int len[maxn];
int book[28], cnt[28];
vector<int> e[28];
queue<int> q;
int topo[28], indx;
inline bool check() {
  for (register int i = 1; i <= 26; ++i)
    if (!cnt[i]) q.push(i), topo[++indx] = i;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (register int i = 0; i < e[t].size(); ++i) {
      --cnt[e[t][i]];
      if (cnt[e[t][i]] == 0) q.push(e[t][i]), topo[++indx] = e[t][i];
    }
  }
  return indx == 26;
}
signed main() {
  P_INIT();
  fin >> n >> k;
  for (register int i = 1; i <= n; ++i) {
    fin >> p;
    for (register int j = 1; j <= k; ++j) {
      scanf("%s", s[p * k + j] + 1), len[p * k + j] = strlen(s[p * k + j] + 1);
      for (register int t = 1; t <= len[p * k + j]; ++t)
        book[s[p * k + j][t] - 'a' + 1] = 1;
    }
  }
  for (register int i = 1; i < n * k; ++i) {
    bool flag = 0;
    for (register int j = 1; j <= std::min(len[i], len[i + 1]); ++j)
      if (s[i][j] != s[i + 1][j]) {
        e[s[i][j] - 'a' + 1].push_back(s[i + 1][j] - 'a' + 1);
        ++cnt[s[i + 1][j] - 'a' + 1];
        flag = 1;
        break;
      }
    if (!flag && len[i] > len[i + 1]) {
      puts("IMPOSSIBLE");
      return 0;
    }
  }
  if (check()) {
    for (register int i = 1; i <= 26; ++i)
      if (book[topo[i]]) fout << char(topo[i] - 1 + 'a');
  } else
    puts("IMPOSSIBLE");
  return 0;
}