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];
vector<string> v[N];
string s1[N];
stack<long long> S;
string ans;
long long q[200];
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);
}
bool isCyclicUtil(int v, bool visited[], bool *recStack) {
  if (visited[v] == false) {
    visited[v] = true;
    recStack[v] = true;
    list<int>::iterator i;
    for (auto it : adj[v]) {
      if (!visited[it] && isCyclicUtil(it, visited, recStack))
        return true;
      else if (recStack[it])
        return true;
    }
  }
  recStack[v] = false;
  return false;
}
bool isCyclic() {
  bool *visited = new bool[200];
  bool *recStack = new bool[200];
  for (int i = 97; i <= 122; i++) {
    visited[i] = false;
    recStack[i] = false;
  }
  for (int i = 97; i <= 122; i++)
    if (isCyclicUtil(i, visited, recStack)) return true;
  return false;
}
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[int(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 (isCyclic() == true) {
    cout << "IMPOSSIBLE";
    return;
  }
  long long x = -1;
  for (long long i = 97; i <= 122; i++) {
    if (q[i] == 0 && vis1[i] != 0) {
      x = i;
      topsort(x, S);
    }
  }
  while (!S.empty()) {
    long long h = S.top();
    S.pop();
    vis1[h] = 0;
    ans += char(h);
  }
  for (long long j = 97; j <= 122; j++) {
    if (vis1[j] == 1) {
      cout << "IMPOSSIBLE";
      return;
    }
  }
  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();
  }
}