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("O3")
#pragma GCC optimize("Ofast")
using namespace std;
const int inf = 0x3f3f3f3f;
using P = pair<int, string>;
const int N = 1e6 + 10;
P a[N];
vector<int> g[30];
int rio[30], in[30];
void exit() {
  cout << "IMPOSSIBLE" << '\n';
  exit(0);
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  string s, s2;
  int id = 0;
  for (int i = 0, p; i < n; i++) {
    cin >> p;
    for (int j = 1; j <= k; j++) {
      cin >> s;
      a[++id] = {p * k + j, s};
    }
  }
  sort(a + 1, a + 1 + id);
  for (int i = 1; i <= id; i++) {
    int len = a[i].second.length();
    s = a[i].second;
    for (int j = 0; j < len; j++) rio[s[j] - 'a'] = 1;
    if (i == 1) continue;
    bool f = 0;
    s2 = a[i - 1].second;
    int len2 = s2.length();
    for (int j = 0; j < min(len2, len); j++) {
      if (s[j] != s2[j]) {
        in[s[j] - 'a']++;
        g[s2[j] - 'a'].push_back(s[j] - 'a');
        f = 1;
        break;
      }
    }
    if (!f && len2 > len) exit();
  }
  queue<int> q;
  for (int i = 0; i < 26; i++)
    if (rio[i] && !in[i]) q.push(i);
  vector<int> res;
  while (!q.empty()) {
    int tp = q.front();
    q.pop();
    res.push_back(tp);
    for (auto x : g[tp]) {
      in[x]--;
      if (!in[x]) q.push(x);
    }
  }
  for (int i = 0; i < 26; i++)
    if (in[i]) exit();
  for (auto it : res) cout << char('a' + it);
  return 0;
}