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
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
const double eps = 1e-7;
const int maxn = 2e6 + 10;
const int prime[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
const int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
int spgcd(int a, int b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
inline int mul(int a, int b, int p) { return (long long)a * b % p; }
template <typename T>
void scan(T &x) {
  x = 0;
  bool _ = 0;
  T c = getchar();
  _ = c == 45;
  c = _ ? getchar() : c;
  while (c < 48 || c > 57) c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
  x = _ ? -x : x;
}
template <typename T>
void printn(T n) {
  bool _ = 0;
  _ = n < 0;
  n = _ ? -n : n;
  char snum[65];
  int i = 0;
  do {
    snum[i++] = n % 10 + 48;
    n /= 10;
  } while (n);
  --i;
  if (_) putchar(45);
  while (i >= 0) putchar(snum[i--]);
}
template <typename First, typename... Ints>
void scan(First &arg, Ints &...rest) {
  scan(arg);
  scan(rest...);
}
template <typename T>
void print(T n) {
  printn(n);
  putchar(10);
}
template <typename First, typename... Ints>
void print(First arg, Ints... rest) {
  printn(arg);
  putchar(32);
  print(rest...);
}
using namespace std;
string s[maxn];
struct node {
  int next, to;
} edge[1010];
int head[1010], cnt;
int vis[50][50], svis[50];
int dg[50];
string ans;
queue<int> q;
void add(int u, int v) {
  edge[cnt] = {head[u], v};
  head[u] = cnt++;
}
bool topu(int num) {
  for (int i = 1; i <= 26; i++) {
    if (svis[i] && dg[i] == 0) {
      q.push(i);
    }
  }
  int snum = 0;
  while (!q.empty()) {
    int now = q.front();
    ans.push_back(now + 'a' - 1);
    q.pop();
    snum++;
    for (int i = head[now]; ~i; i = edge[i].next) {
      int tp = edge[i].to;
      dg[tp]--;
      if (!dg[tp]) q.push(tp);
    }
  }
  return snum == num;
}
void solve() {
  int n, k;
  int num = 0;
  memset(head, -1, sizeof head);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < k; j++) cin >> s[x * k + j];
  }
  if (n * k == 1) {
    sort((s[0]).begin(), (s[0]).end());
    s[0].resize(unique((s[0]).begin(), (s[0]).end()) - s[0].begin());
    cout << s[0] << endl;
    return;
  }
  for (int i = 1; i < n * k; i++) {
    int flag = 0;
    for (int j = 0; j < min(s[i].size(), s[i - 1].size()); j++) {
      int u = s[i - 1][j] - 'a' + 1, v = s[i][j] - 'a' + 1;
      if (!svis[u]) num++, svis[u] = 1;
      if (!svis[v]) num++, svis[v] = 1;
      if (u != v) {
        flag = 1;
        if (vis[u][v] == 0) {
          vis[u][v] = 1;
          add(u, v);
          dg[v]++;
        }
        break;
      }
    }
    if (!flag && s[i].size() < s[i - 1].size()) {
      cout << "IMPOSSIBLE" << endl;
      return;
    }
  }
  if (topu(num)) {
    cout << ans << endl;
  } else
    cout << "IMPOSSIBLE" << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
  return 0;
}
