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>
using namespace std;
vector<int> primes;
void Sieve(int n) {
  vector<bool> prime(n + 1, true);
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
int dnc(int bas, int power, int mod) {
  if (power == 0) return 1;
  if (power % 2 == 0) {
    int res = dnc(bas, power / 2, mod);
    return 1LL * res * res % mod;
  }
  return 1LL * bas * dnc(bas, power - 1, mod) % mod;
}
int f[2 * 300010 + 1], inv[2 * 300010 + 1];
void precalc() {
  f[0] = inv[0] = 1;
  for (int temp = 1; temp <= 2 * 300010; temp++) {
    f[temp] = 1ll * temp * f[temp - 1] % 10000007;
    inv[temp] = dnc(temp, 10000007 - 2, 10000007) * inv[temp - 1] % 10000007;
  }
}
int comb(int n, int k) {
  if (k > n || k < 0) return 0;
  return f[n] * inv[k] % 10000007 * inv[n - k] % 10000007;
}
stack<int> st;
vector<bool> visited(26, 0);
vector<vector<int>> vec(26);
void toposort(int x) {
  visited[x] = 1;
  for (int i = 0; i < vec[x].size(); i++) {
    if (!visited[vec[x][i]]) toposort(vec[x][i]);
  }
  st.push(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n;
  cin >> k;
  set<char> z;
  vector<string> sq(n * k);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    for (int j = 0; j < k; j++) cin >> sq[p * k + j];
  }
  vector<vector<bool>> fg(26, vector<bool>(26, 0));
  for (int i = 0; i < n * k; i++) {
    if (i + 1 < n * k) {
      int j = -1;
      while (j + 1 < min(sq[i].size(), sq[i + 1].size()) &&
             sq[i][j + 1] == sq[i + 1][j + 1]) {
        j++;
      }
      j++;
      if (j != min(sq[i].size(), sq[i + 1].size()))
        fg[sq[i][j] - 'a'][sq[i + 1][j] - 'a'] = 1;
      else {
        if (sq[i].size() > sq[i + 1].size()) {
          cout << "IMPOSSIBLE";
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < n * k; i++) {
    for (int j = 0; j < sq[i].size(); j++) z.insert(sq[i][j] - 'a');
    if (z.size() == 26) break;
  }
  bool flag = true;
  for (int i = 0; i < 26; i++) {
    for (int j = i + 1; j < 26; j++) {
      if (fg[i][j] && fg[j][i])
        flag = false;
      else if (fg[i][j])
        vec[i].push_back(j);
      else if (fg[j][i])
        vec[j].push_back(i);
    }
  }
  if (!flag)
    cout << "IMPOSSIBLE";
  else {
    for (int i = 0; i < 26; i++) {
      if (!visited[i]) toposort(i);
    }
    string ans;
    while (!st.empty()) {
      int x = st.top();
      st.pop();
      ans += char(97 + x);
    }
    for (int i = 0; i < 26; i++) {
      if (z.find(i) == z.end())
        ans.erase(remove(ans.begin(), ans.end(), char(97 + i)), ans.end());
    }
    for (int i = 0; i < ans.size(); i++) {
      for (int j = i + 1; j < ans.size(); j++) {
        if (fg[ans[j] - 'a'][ans[i] - 'a']) {
          cout << "IMPOSSIBLE";
          return 0;
        }
      }
    }
    cout << ans;
  }
  return 0;
}