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;
const int N = 1010, K = 105, NN = 30;
struct page {
  char s1[K], s2[K];
  int l1, l2;
} a1[N];
struct edge {
  int next, y;
} data[N * N];
queue<int> q;
char str[3][K];
int n, t, cnt, cnt1, num, h[NN], in[NN], l[3], tid[NN], f1[NN];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
inline int min1(int i, int j) { return i < j ? i : j; }
inline void addedge(int u, int v) {
  data[++num].y = v, data[num].next = h[u], h[u] = num, ++in[v];
}
int main() {
  n = read(), t = read();
  num = 0;
  memset(in, 0, sizeof in);
  memset(h, -1, sizeof h);
  memset(f1, 0, sizeof f1);
  for (int i = 1, p, id; i <= n; ++i) {
    p = read();
    scanf("%s", str[1] + 1);
    a1[p].l1 = l[1] = strlen(str[1] + 1);
    for (int j = 1; j <= l[1]; ++j)
      a1[p].s1[j] = str[1][j], f1[str[1][j] - 'a'] = 1;
    for (int j = 2, k, l1; j <= t; ++j) {
      id = j % 2;
      scanf("%s", str[id] + 1);
      l[id] = strlen(str[id] + 1);
      for (k = 1; k <= l[id]; ++k) f1[str[id][k] - 'a'] = 1;
      l1 = min1(l[id], l[1 - id]);
      for (k = 1; k <= l1; ++k)
        if (str[id][k] != str[1 - id][k]) break;
      if (l[1 - id] > l[id] && k > l[id]) {
        printf("IMPOSSIBLE");
        return 0;
      }
      if (k <= l[1 - id]) {
        addedge(str[1 - id][k] - 'a', str[id][k] - 'a');
      }
    }
    a1[p].l2 = l[id];
    for (int j = 1; j <= l[id]; ++j) a1[p].s2[j] = str[id][j];
  }
  for (int i = 1, l1, k; i < n; ++i) {
    l1 = min1(a1[i - 1].l2, a1[i].l1);
    for (k = 1; k <= l1; ++k)
      if (a1[i - 1].s2[k] != a1[i].s1[k]) break;
    if (a1[i - 1].l2 > a1[i].l1 && k > a1[i].l1) {
      printf("IMPOSSIBLE");
      return 0;
    }
    if (k <= a1[i - 1].l2) {
      addedge(a1[i - 1].s2[k] - 'a', a1[i].s1[k] - 'a');
    }
  }
  cnt = cnt1 = 0;
  while (!q.empty()) q.pop();
  for (int i = 0; i < 26; ++i)
    if (f1[i]) {
      ++cnt1;
      if (!in[i]) q.push(i);
    }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ++cnt;
    tid[cnt] = u;
    for (int i = h[u], v; i != -1; i = data[i].next) {
      v = data[i].y;
      --in[v];
      if (!in[v]) q.push(v);
    }
  }
  if (cnt != cnt1) {
    printf("IMPOSSIBLE");
    return 0;
  }
  for (int i = 1; i <= cnt; ++i) printf("%c", tid[i] + 'a');
  return 0;
}