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>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const long double eps = 1e-8;
const int mod = 998244353;
const int maxn = 2e5 + 100;
const int N = 1e5 + 100;
const int M = 1e5 + 10;
const long long mm = (1LL << 32);
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  x = f ? -x : x;
}
template <class T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  T y = 1;
  int len = 1;
  for (; y <= x / 10; y *= 10) ++len;
  for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
long long qpow(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
int n, k, du[2000];
vector<int> g[2000];
vector<string> a[2000];
vector<string> s;
map<int, int> mp;
int vis[30][30];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    string t;
    for (int j = 1; j <= k; ++j) {
      cin >> t;
      a[x].push_back(t);
    }
  }
  for (int i = 0; i <= n; ++i) {
    int sz = a[i].size();
    if (sz > 0) {
      for (int j = 0; j < k; ++j) {
        s.push_back(a[i][j]);
      }
    }
  }
  int tag = 0;
  for (string tt : s)
    for (char c : tt) mp[c - 'a'] = 1;
  for (int i = 0; i < 26; ++i)
    if (mp[i]) tag++;
  n = s.size();
  for (int i = 1; i < n; ++i) {
    int len1 = s[i - 1].size(), len2 = s[i].size(), flag = 0;
    int mi = min(len1, len2);
    for (int j = 0; j < mi; ++j) {
      if (s[i - 1][j] == s[i][j]) continue;
      flag = 1;
      int u = s[i - 1][j] - 'a', v = s[i][j] - 'a';
      if (!vis[u][v]) g[u].push_back(v), du[v]++;
      vis[u][v] = 1;
      break;
    }
    if (flag == 0 && len1 > len2) {
      cout << "IMPOSSIBLE";
      return 0;
    }
  }
  queue<int> q;
  for (int i = 0; i < 26; ++i) {
    if (mp[i] && !du[i]) q.push(i);
  }
  string ans = "";
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ans += u + 'a';
    for (int v : g[u]) {
      du[v]--;
      if (du[v] == 0) q.push(v);
    }
  }
  if ((int)ans.size() == tag)
    cout << ans;
  else
    cout << "IMPOSSIBLE";
  return 0;
}