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;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <class T>
void mxi(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void mni(T& a, const T& b) {
  a = min(a, b);
}
long double EPS = 1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
vector<vector<string>> v;
vector<vector<int>> g;
int indeg[27], vis[27];
void solve() {
  int n, k;
  cin >> n >> k;
  v.resize(n);
  g.resize(27);
  int nn = 0;
  while (nn < n) {
    int p;
    cin >> p;
    for (int i = 0; i < (k); i++) {
      string s;
      cin >> s;
      for (auto ch : s) vis[ch - 'a']++;
      v[p].push_back(s);
    }
    nn++;
  }
  vector<string> rel;
  for (int i = 0; i < n; i++)
    for (auto x : v[i]) rel.push_back(x);
  nn = (long long)(rel).size();
  for (int i = 0; i < nn - 1; i++) {
    string s1 = rel[i], s2 = rel[i + 1];
    int id = 0, f = 0;
    while (id < min((long long)(s1).size(), (long long)(s2).size())) {
      if (s1[id] != s2[id]) {
        f = 1;
        g[s1[id] - 'a'].push_back(s2[id] - 'a');
        indeg[s2[id] - 'a']++;
        break;
      }
      id++;
    }
    if (!f && (long long)(s1).size() > (long long)(s2).size()) {
      cout << "IMPOSSIBLE\n";
      return;
    }
  }
  vector<int> topo;
  int chalbey = 0;
  queue<int> q;
  for (int i = 0; i < 26; i++) {
    if (vis[i] && indeg[i] == 0) q.push(i);
    if (vis[i]) chalbey++;
  }
  while ((long long)(q).size()) {
    int tmp = q.front();
    q.pop();
    topo.push_back(tmp);
    for (auto x : g[tmp]) {
      indeg[x]--;
      if (indeg[x] == 0) q.push(x);
    }
  }
  if ((long long)(topo).size() == chalbey) {
    for (auto x : topo) cout << (char)(x + 'a');
    cout << '\n';
  } else
    cout << "IMPOSSIBLE\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, tab;
  t = 1;
  tab = t;
  while (t--) {
    solve();
  }
  cerr << ((double)clock() / CLOCKS_PER_SEC);
}