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 JAVA):

Solution:
//stan hu tao
//join nct ridin by first year culture reps
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;

public class x1424M
{
    static boolean[][] edges;
    public static void main(String hi[]) throws Exception
    {
        FastScanner infile = new FastScanner();
        int N = infile.nextInt();
        int K = infile.nextInt();
        String[] arr = new String[N*K];
        for(int i=0; i < N; i++)
        {
            int head = infile.nextInt()*K;
            for(int a=0; a < K; a++)
                arr[head++] = infile.next();
        }
        edges = new boolean[26][26];
        boolean[] found = new boolean[26];
        for(char c: arr[0].toCharArray())
            found[c-'a'] = true;
        for(int a=1; a < N*K; a++)
        {
            int M = min(arr[a-1].length(), arr[a].length());
            boolean diff = false;
            for(int i=0; i < M; i++)
            {
                found[arr[a-1].charAt(i)-'a'] = found[arr[a].charAt(i)-'a'] = true;
                if(arr[a-1].charAt(i) != arr[a].charAt(i))
                {
                    edges[arr[a-1].charAt(i)-'a'][arr[a].charAt(i)-'a'] = true;
                    diff = true;
                    break;
                }
            }
            String lol = arr[a];
            if(arr[a-1].length() > arr[a].length() && !diff)
            {
                System.out.println("IMPOSSIBLE");
                return;
            }
            for(int i=M; i < lol.length(); i++)
                found[lol.charAt(i)-'a'] = true;
        }
        seen = new boolean[26];
        ArrayList<Integer> topsort = new ArrayList<Integer>();
        for(int v=0; v < 26; v++)
            if(!seen[v])
                dfs(v, topsort);
        Collections.reverse(topsort);
        int[] loc = new int[26];
        for(int v=0; v < 26; v++)
            loc[topsort.get(v)] = v;
        for(int a=0; a < 26; a++)
            for(int b=0; b < 26; b++)
                if(edges[a][b] && loc[a] > loc[b])
                {
                    System.out.println("IMPOSSIBLE");
                    return;
                }
        String res = "";
        for(int x: topsort)
            if(found[x])
                res += (char)(x+'a');
        System.out.println(res);
    }
    static boolean[] seen;
    public static void dfs(int curr, ArrayList<Integer> ls)
    {
        seen[curr] = true;
        for(int next=0; next < 26; next++)
            if(edges[curr][next] && !seen[next])
                dfs(next, ls);
        ls.add(curr);
    }
}
class FastScanner
{
    private int BS = 1 << 16;
    private char NC = (char) 0;
    private byte[] buf = new byte[BS];
    private int bId = 0, size = 0;
    private char c = NC;
    private double cnt = 1;
    private BufferedInputStream in;

    public FastScanner() {
        in = new BufferedInputStream(System.in, BS);
    }

    public FastScanner(String s) {
        try {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        } catch (Exception e) {
            in = new BufferedInputStream(System.in, BS);
        }
    }

    private char getChar() {
        while (bId == size) {
            try {
                size = in.read(buf);
            } catch (Exception e) {
                return NC;
            }
            if (size == -1) return NC;
            bId = 0;
        }
        return (char) buf[bId++];
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public int[] nextInts(int N) {
        int[] res = new int[N];
        for (int i = 0; i < N; i++) {
            res[i] = (int) nextLong();
        }
        return res;
    }

    public long[] nextLongs(int N) {
        long[] res = new long[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextLong();
        }
        return res;
    }

    public long nextLong() {
        cnt = 1;
        boolean neg = false;
        if (c == NC) c = getChar();
        for (; (c < '0' || c > '9'); c = getChar()) {
            if (c == '-') neg = true;
        }
        long res = 0;
        for (; c >= '0' && c <= '9'; c = getChar()) {
            res = (res << 3) + (res << 1) + c - '0';
            cnt *= 10;
        }
        return neg ? -res : res;
    }

    public double nextDouble() {
        double cur = nextLong();
        return c != '.' ? cur : cur + nextLong() / cnt;
    }

    public double[] nextDoubles(int N) {
        double[] res = new double[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextDouble();
        }
        return res;
    }

    public String next() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c > 32) {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public String nextLine() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c != '\n') {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public boolean hasNext() {
        if (c > 32) return true;
        while (true) {
            c = getChar();
            if (c == NC) return false;
            else if (c > 32) return true;
        }
    }
}