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("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const long long N = 1e+6 + 7;
vector<long long> adj[N];
long long vis[N] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
int t = 1;
long long n, k, p, vis1[N], q[200];
vector<string> v[N];
string s1[N], ans;
stack<long long> S;
void topsort(long long x, stack<long long> &Stack) {
  vis[x] = 1;
  for (auto it : adj[x]) {
    if (vis[it]) continue;
    topsort(it, Stack);
  }
  Stack.push(x);
}
vector<long long> parent, color;
long long cycle_start, cycle_end;
long long dfs(int v) {
  color[v] = 1;
  for (int u : adj[v]) {
    if (color[u] == 0) {
      parent[u] = v;
      if (dfs(u)) return 1;
    } else if (color[u] == 1) {
      cycle_end = v;
      cycle_start = u;
      return 1;
    }
  }
  color[v] = 2;
  return 0;
}
long long find_cycle() {
  color.assign(200, 0);
  parent.assign(200, -1);
  for (long long v = 97; v <= 122; v++) {
    if (color[v] == 0 && dfs(v)) return 1;
  }
  return 0;
}
void MAIN() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> p;
    for (long long j = 1; j <= k; j++) {
      string second;
      cin >> second;
      v[p].push_back(second);
      for (long long h = 0; h < second.size(); h++) {
        vis1[second[h]] = 1;
      }
    }
  }
  long long counter = 1;
  for (long long i = 0; i < n; i++) {
    for (auto it : v[i]) {
      s1[counter] = it;
      counter++;
    }
  }
  for (long long i = 1; i < counter - 1; i++) {
    long long l1 = 0;
    long long l2 = 0;
    long long first = 0;
    long long len1 = s1[i].size();
    long long len2 = s1[i + 1].size();
    while (l1 < len1 && l2 < len2) {
      if (s1[i][l1] == s1[i + 1][l2]) {
        l1++;
        l2++;
        continue;
      } else {
        auto it = std::find(adj[s1[i][l1]].begin(), adj[s1[i][l1]].end(),
                            s1[i + 1][l2]);
        if (it == adj[s1[i][l1]].end()) adj[s1[i][l1]].push_back(s1[i + 1][l2]);
        q[s1[i + 1][l2]]++;
        first = 1;
        break;
      }
    }
    if (!first) {
      if (len2 < len1) {
        cout << "IMPOSSIBLE";
        return;
      }
    }
  }
  if (find_cycle()) {
    cout << "IMPOSSIBLE";
    return;
  }
  for (long long i = 97; i <= 122; i++) {
    if (q[i] == 0 && vis1[i] != 0) topsort(i, S);
  }
  while (!S.empty()) {
    long long h = S.top();
    S.pop();
    vis1[h] = 0;
    ans += char(h);
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  ;
  mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  ;
  while (t--) {
    MAIN();
  }
}