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;
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int binary_search(std::vector<int>& s, std::vector<int>& height, int first,
                  int last, int x) {
  while (last > first) {
    int mid = first + (last - first) / 2;
    if (height[s[mid]] > x)
      last = mid;
    else
      first = mid + 1;
  }
  return first;
}
int LongestIncreasingSubsequenceLength(std::vector<int>& height) {
  if (height.size() == 0) return 0;
  int n = height.size();
  int i, k, index;
  std::vector<int> s(height.size() + 1, 0);
  index = 1;
  s[1] = 0;
  for (i = 1; i < n; i++) {
    if (height[i] >= height[s[index]]) {
      index++;
      s[index] = i;
    } else {
      k = binary_search(s, height, 1, index, height[i]);
      if (height[s[k]] >= height[i]) {
        s[k] = i;
      }
    }
  }
  return index;
}
void solve() {
  int n, k;
  cin >> n >> k;
  string s[n][k];
  vector<string> lol;
  int A[26][26] = {0};
  int visit[26] = {0};
  for (int i = 0; i < 26; i++) {
    visit[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < k; j++) {
      cin >> s[a][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      lol.push_back(s[i][j]);
    }
  }
  int y = lol.size();
  int count = 0, flag = 1;
  for (int i = 0; i < y - 1; i++) {
    int a = lol[i].size();
    int b = lol[i + 1].size();
    for (int j = 0; j < min(a, b); j++) {
      if (lol[i][j] != lol[i + 1][j]) {
        A[lol[i][j] - 'a'][lol[i + 1][j] - 'a'] = 1;
        break;
      }
      if (j == min(a, b) - 1 && a > b) {
        flag = 0;
      }
    }
  }
  for (int i = 0; i < y; i++) {
    int a = lol[i].size();
    for (int j = 0; j < a; j++) {
      visit[lol[i][j] - 'a'] = 0;
    }
  }
  for (int i = 0; i < 26; i++) {
    count += visit[i];
  }
  string f = "";
  if (flag == 0) {
    cout << "IMPOSSIBLE";
    return;
  }
  for (int i = 0; i < 26 - count; i++) {
    int b = -1;
    for (int j = 0; j < 26; j++) {
      int val = 0;
      for (int k = 0; k < 26; k++) {
        val += A[j][k];
      }
      if (val == 0 && visit[j] == 0) {
        b = j;
        break;
      }
    }
    if (b == -1) {
      cout << "IMPOSSIBLE";
      return;
    }
    visit[b] = 1;
    for (int k = 0; k < 26; k++) {
      A[k][b] = 0;
    }
    if (b != -1) f = (char)('a' + b) + f;
  }
  cout << f;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}