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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
using ll = long long;
using ld = long double;
using db = double;
using pii = pair<ll, ll>;
using pli = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<db, db>;
using vi = vector<ll>;
using vl = vector<ll>;
using vb = vector<bool>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pii>;
using vpl = vector<pll>;
using vpd = vector<pdd>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll x) { return (unsigned long long)rng() % x; }
const ll mod = 1000000007;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template <class t, class u>
void chmax(t& a, u b) {
  if (a < b) a = b;
}
template <class t, class u>
void chmin(t& a, u b) {
  if (b < a) a = b;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector<vector<string>> a(n);
  vector<bool> present(26, 0);
  for (ll i = 0; i < n; i++) {
    ll ind;
    cin >> ind;
    for (ll j = 0; j < k; j++) {
      string str;
      cin >> str;
      for (ll l = 0; l < ((ll)(str).size()); l++) present[str[l] - 'a'] = 1;
      a[ind].push_back(str);
    }
  }
  vector<string> order;
  for (ll i = 0; i < n; i++) {
    for (auto x : a[i]) order.push_back(x);
    a[i].clear();
  }
  a.clear();
  42;
  queue<pair<pii, ll>> q;
  q.push(make_pair(make_pair(0, ((ll)(order).size())), 0));
  vector<string> pos;
  while (!q.empty()) {
    pair<pii, ll> got = q.front();
    42;
    q.pop();
    string fake = "";
    for (ll i = got.first.first; i < got.first.second; i++) {
      if (((ll)(order[i]).size()) <= got.second) continue;
      fake += order[i][got.second];
    }
    string real = "";
    for (ll i = 0; i < ((ll)(fake).size()); i++) {
      if (i == 0 || fake[i] != fake[i - 1]) real += fake[i];
    }
    pos.push_back(real);
    ll ind = got.second + 1;
    ll cur = got.first.first;
    for (ll i = got.first.first; i < got.first.second; i++) {
      if (i > got.first.first && ((ll)(order[i]).size()) <= ind &&
          ((ll)(order[i - 1]).size()) > ind &&
          order[i - 1][ind - 1] == order[i][ind - 1]) {
        cout << "IMPOSSIBLE\n";
        return 0;
      }
      if (((ll)(order[i]).size()) <= ind && cur == i) {
        cur++;
        continue;
      }
      if (((ll)(order[i]).size()) <= ind) {
        if (cur < i - 1) q.push(make_pair(make_pair(cur, i), ind));
        cur = i + 1;
        continue;
      }
      if (i > 0 && ((ll)(order[i - 1]).size()) > ind &&
          order[i][ind - 1] != order[i - 1][ind - 1]) {
        42;
        if (cur < i - 1) q.push(make_pair(make_pair(cur, i), ind));
        cur = i;
      }
    }
    if (cur < got.first.second - 1) {
      q.push(make_pair(make_pair(cur, got.first.second), ind));
    }
  }
  order.clear();
  42;
  map<char, set<char>> left;
  for (ll i = 0; i < 26; i++) {
    if (!present[i]) continue;
    left['a' + i].insert('a' + i);
  }
  for (auto x : pos) {
    for (ll i = 0; i < ((ll)(x).size()); i++) {
      for (ll j = 0; j < i; j++) {
        left[x[i]].insert(x[j]);
      }
    }
  }
  pos.clear();
  for (auto x : left) left[x.first].erase(x.first);
  queue<char> charorder;
  for (auto x : left) {
    if (x.second.empty()) {
      charorder.push(x.first);
    }
  }
  if (charorder.empty()) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  string ans = "";
  while (!charorder.empty()) {
    ans += charorder.front();
    for (auto x : left) {
      if (x.second.empty()) continue;
      left[x.first].erase(charorder.front());
      if (left[x.first].empty()) charorder.push(x.first);
    }
    charorder.pop();
  }
  for (auto x : left)
    if (!x.second.empty()) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
  cout << ans << '\n';
}