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 int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const long long INF64 = 1e18;
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(const vector<T> &v) {
  string ret = "<";
  for (auto it : v) ret += to_string(it) + ", ";
  ret.pop_back();
  ret.pop_back();
  ret += ">";
  return ret;
}
void debug_print() { cerr << endl; }
template <typename T, typename... U>
void debug_print(T t, U... u) {
  cerr << " " << to_string(t);
  debug_print(u...);
}
const int N = 1e5 + 5;
struct Page {
  int num;
  vector<string> v;
  bool operator<(const Page &other) const { return num < other.num; }
};
long long n, k;
vector<Page> p;
vector<string> dic;
vector<int> adj[70];
vector<int> ord;
;
bool mat[70][70];
bool cycle = false;
bool isExist[70];
int col[70];
int to_num(char x) {
  if (islower(x)) return x - 'a';
  return x - 'A' + 26;
}
char to_ch(int x) {
  if (x < 26) return x + 'a';
  return x + 'A';
}
void dfs(int v) {
  col[v] = 1;
  for (auto it : adj[v]) {
    if (col[it] == 1) {
      cycle = true;
    }
    if (col[it] == 0) {
      dfs(it);
    }
  }
  ord.push_back(v);
  col[v] = 2;
}
bool toposort() {
  memset((col), 0, sizeof(col));
  for (int i = 0; i < 70; i++) {
    if (!isExist[i] || col[i] != 0) continue;
    dfs(i);
  }
  if (cycle) return false;
  reverse(ord.begin(), ord.end());
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  p.resize(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p[i].num = x;
    for (int j = 0; j < k; j++) {
      string s;
      cin >> s;
      for (char c : s) {
        isExist[to_num(c)] = 1;
      }
      p[i].v.push_back(s);
    }
  }
  sort(p.begin(), p.end());
  dic.resize(n * k);
  for (int i = 0; i < n; i++) {
    if (i + 1 < n) assert(p[i].num != p[i + 1].num);
    for (int j = 0; j < k; j++) {
      dic[i * k + j] = p[i].v[j];
    }
  }
  for (int i = 1; i < n * k; i++) {
    int a = dic[i].size();
    int b = dic[i - 1].size();
    bool br = false;
    for (int j = 0; j < min(a, b); j++) {
      if (dic[i][j] != dic[i - 1][j]) {
        if (!mat[to_num(dic[i - 1][j])][to_num(dic[i][j])]) {
          mat[to_num(dic[i - 1][j])][to_num(dic[i][j])] = 1;
          adj[to_num(dic[i - 1][j])].push_back(to_num(dic[i][j]));
        }
        b = true;
        break;
      }
    }
    if (!br && a < b) cycle = true;
  }
  if (!toposort()) {
    cout << "IMPOSSIBLE" << '\n';
    return 0;
  }
  for (auto it : ord) {
    cout << to_ch(it);
  }
  cout << '\n';
  return 0;
}