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;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
vector<long long> g[30];
vector<long long> ans;
long long vis[30];
long long on[30];
long long fl;
void dfs(long long s, long long pa) {
  vis[s] = 1;
  on[s] = 1;
  for (long long i = 0; i < g[s].size(); i++) {
    if (vis[g[s][i]] == 0) {
      dfs(g[s][i], s);
    } else {
      if (on[g[s][i]]) {
        fl = 1;
      }
    }
  }
  on[s] = 0;
  ans.push_back(s);
}
vector<string> gg[1100];
bool srt(pair<pair<long long, long long>, string> a,
         pair<pair<long long, long long>, string> b) {
  if (a.first.first != b.first.first)
    return a.first.first < b.first.first;
  else
    return a.first.second < b.first.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k, i;
  cin >> n >> k;
  vector<pair<pair<long long, long long>, string> > vp;
  vector<long long> found(30, 0);
  for (i = 0; i < n; i++) {
    long long y;
    cin >> y;
    for (long long j = 0; j < k; j++) {
      string s;
      cin >> s;
      gg[y].push_back(s);
      for (auto e : s) {
        found[e - 'a'] = 1;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (long long j = 0; j < gg[i].size(); j++) {
      vp.push_back(make_pair(make_pair(i, j), gg[i][j]));
    }
  }
  set<pair<long long, long long> > st;
  for (i = 1; i < vp.size(); i++) {
    long long j = 0;
    while (j < vp[i - 1].second.length() && j < vp[i].second.length()) {
      if (vp[i - 1].second[j] != vp[i].second[j]) {
        if (st.find(make_pair(vp[i - 1].second[j] - 'a',
                              vp[i].second[j] - 'a')) == st.end()) {
          g[vp[i - 1].second[j] - 'a'].push_back(vp[i].second[j] - 'a');
          st.insert(
              make_pair(vp[i - 1].second[j] - 'a', vp[i].second[j] - 'a'));
        }
        break;
      }
      j++;
    }
    if (j == vp[i].second.length() && j < vp[i - 1].second.length()) {
      fl = 1;
    }
  }
  if (fl) {
    cout << "IMPOSSIBLE";
    return 0;
  }
  for (i = 0; i < 26; i++) {
    if (vis[i] == 0) {
      dfs(i, -1);
    }
  }
  if (fl) {
    cout << "IMPOSSIBLE";
    return 0;
  } else {
    for (i = ans.size() - 1; i >= 0; i--) {
      if (found[ans[i]] == 0) continue;
      char ch = ans[i] + 'a';
      cout << ch;
    }
  }
  return 0;
}