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;
const long long MAX = 1000000000000000000;
long long mod = 1000000000;
long double pi = 3.141592653589793238;
void pls() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long N = 1e3 + 2;
vector<string> temp[N];
vector<long long> g[28], G[28];
long long connected;
vector<long long> deg(N, 0);
unordered_map<char, long long> conv;
vector<string> arr;
unordered_map<long long, char> rmp;
void dfs(int ix, vector<long long> &visi) {
  visi[ix] = 1;
  connected++;
  for (auto x : G[ix]) {
    if (!visi[x]) dfs(x, visi);
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long p;
    cin >> p;
    for (int j = 0; j < k; j++) {
      string s;
      cin >> s;
      temp[p].push_back(s);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < temp[i].size(); j++) arr.push_back(temp[i][j]);
  }
  long long cnt = 1;
  for (int i = 0; i < arr.size(); i++) {
    for (auto x : arr[i]) {
      if (conv.find(x) == conv.end()) conv[x] = cnt++;
    }
    if (i) {
      bool ok = false;
      int j = 0;
      for (; j < arr[i].size() && j < arr[i - 1].size(); j++) {
        if (arr[i - 1][j] != arr[i][j]) {
          long long u = conv[arr[i - 1][j]];
          long long v = conv[arr[i][j]];
          g[u].push_back(v);
          G[u].push_back(v);
          G[v].push_back(u);
          ok = true;
          deg[v]++;
          break;
        }
      }
      if (!ok && j < arr[i - 1].size()) {
        cout << "IMPOSSIBLE";
        return;
      }
    }
  }
  string res = "";
  for (auto x : conv) rmp[x.second] = x.first;
  queue<long long> q;
  for (int i = 1; i < cnt; i++) {
    if (deg[i] == 0) q.push(i);
  }
  while (!q.empty()) {
    long long ix = q.front();
    q.pop();
    res += rmp[ix];
    for (auto x : g[ix]) {
      deg[x]--;
      if (deg[x] == 0) q.push(x);
    }
  }
  if (res.size() == conv.size())
    cout << res << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}
int main() {
  pls();
  solve();
  return 0;
}