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;
bool rev(long long x, long long y) { return x > y; }
void input_arr(long long a[], long long n) {
  for (long long i = 0; i < n; i += 1) cin >> a[i];
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return a.second < b.second;
}
bool sortinrev(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.first > b.first);
}
void print_vec(vector<long long> &v) {
  for (auto i : v) cout << i << " ";
  cout << '\n';
}
bool sortinrevbysec(const pair<long long, long long> &a,
                    const pair<long long, long long> &b) {
  return (a.second > b.second);
}
void print_arr(long long a[], long long n) {
  for (long long i = 0; i < n; i += 1) cout << a[i] << " ";
  cout << '\n';
}
template <typename... T>
void input(T &...args) {
  ((cin >> args), ...);
}
template <typename... T>
void print(T &&...args) {
  ((cout << args << '\n'), ...);
}
template <typename... T>
void deb(T &&...args) {
  cout << "~~ ";
  ((cout << args << " "), ...);
  cout << '\n';
}
vector<string> vs;
map<pair<char, char>, long long> mpp;
string s, t;
vector<long long> visited(26, 0);
vector<vector<long long>> vv_(26);
vector<long long> v_;
void topo_sort(long long x) {
  visited[x]++;
  for (auto vbn : vv_[x]) {
    if (visited[vbn] == 0) {
      topo_sort(vbn);
    }
  }
  v_.push_back(x);
}
void stand8th() {
  long long n, k, p;
  input(n, k);
  for (long long i = 0; i < n * k; i += 1) vs.push_back("#");
  for (long long i = 0; i < n; i += 1) {
    input(p);
    for (long long j = 0; j < k; j += 1) input(vs[p * k + j]);
  }
  map<char, long long> mapp;
  for (auto vbn : vs) {
    for (long long i = 0; i < (long long)(vbn.size()); i += 1) mapp[vbn[i]]++;
  }
  for (long long g = 1; g < (long long)(vs.size()); g += 1) {
    s = vs[g - 1];
    t = vs[g];
    long long fll = 0;
    for (long long i = 0; i < min((long long)(s.size()), (long long)(t.size()));
         i += 1) {
      if (s[i] != t[i]) {
        vv_[(long long)(s[i] - 'a')].push_back((long long)(t[i] - 'a'));
        mpp[{s[i], t[i]}]++;
        fll++;
        break;
      }
    }
    if (fll == 0 && (long long)(s.size()) > (long long)(t.size())) {
      print("IMPOSSIBLE");
      return;
    }
  }
  for (long long i = 0; i < 26; i += 1) {
    for (long long j = i + 1; j < 26; j += 1) {
      char c = 'a' + i, d = 'a' + j;
      if (mpp[{c, d}] > 0 && mpp[{d, c}] > 0) {
        print("IMPOSSIBLE");
        return;
      }
    }
  }
  vector<long long> rtt;
  for (long long i = 0; i < 26; i += 1) {
    long long fl = 0;
    char c = 'a' + i;
    for (auto vbn : mpp) {
      if (vbn.second > 0 && vbn.first.second == c) {
        fl++;
        break;
      }
    }
    if (fl == 0) rtt.push_back(i);
  }
  for (auto vbn : rtt) {
    if (visited[vbn] == 0) {
      topo_sort(vbn);
    }
  }
  reverse((v_).begin(), (v_).end());
  string ans;
  for (auto vbn : v_) {
    ans += (char)('a' + vbn);
  }
  if ((long long)(ans.size()) != 26) {
    print("IMPOSSIBLE");
    return;
  }
  for (long long i = 0; i < (long long)(ans.size()); i += 1) {
    for (long long j = i + 1; j < (long long)(ans.size()); j += 1) {
      if (mpp[{ans[j], ans[i]}] > 0) {
        print("IMPOSSIBLE");
        return;
      }
    }
  }
  for (long long i = 0; i < (long long)(ans.size()); i += 1) {
    if (mapp[ans[i]] > 0) cout << ans[i];
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tin = 1;
  while (tin--) {
    stand8th();
  }
  return 0;
}