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:
/**
 * author: derrick20
 * created: 10/5/20 10:11 AM
 */
import java.io.*;
import java.util.*;

public class MAncientLanguage implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new MAncientLanguage(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int K = sc.nextInt();

        adjList = new ArrayList[26];
        Arrays.setAll(adjList, i -> new ArrayList<>());
        ArrayList<String> words = new ArrayList<>();
        ArrayList<String>[] pages = new ArrayList[N];
        HashSet<Character> letters = new HashSet<>();

        for (int i = 0; i < N; i++) {
            int page = sc.nextInt();
            pages[page] = new ArrayList<>();
            for (int j = 0; j < K; j++) {
                String s = sc.next();
                pages[page].add(s);
                for (char c : s.toCharArray()) {
                    letters.add(c);
                }
            }
        }
        for (int i = 0; i < N; i++) {
            words.addAll(pages[i]);
        }
        String prev = words.get(0);
        boolean poss = true;
        for (int i = 1; i < words.size(); i++) {
            String curr = words.get(i);
            int len = Math.min(prev.length(), curr.length());
//            System.out.println(prev + " " + curr);
            boolean equal = true;
            for (int pos = 0; pos < len; pos++) {
                int c1 = prev.charAt(pos) - 'a';
                int c2 = curr.charAt(pos) - 'a';
                if (c1 != c2) {
                    adjList[c1].add(c2);
                    equal = false;
                    break;
                }
            }
            if (equal && prev.length() > curr.length()) {
                poss = false;
                break;
            }
            prev = curr;
        }
        vis = new int[26];
        res = new StringBuilder();
        for (int c = 0; c < 26; c++) {
            if (letters.contains((char) (c + 'a'))) {
                dfs(c);
            }
        }
        res.reverse();
        if (!cycle && poss) {
            out.println(res);
        } else {
            out.println("IMPOSSIBLE");
        }
        out.close();
    }

    static ArrayList<Integer>[] adjList;
    static StringBuilder res;
    static int[] vis;
    static boolean cycle;

    static void dfs(int node) {
        if (vis[node] == 2) return;
        else if (vis[node] == 1) {
            cycle = true;
            return;
        } else {
            vis[node] = 1;
            for (int adj : adjList[node]) {
                dfs(adj);
            }
            res.append((char) (node + 'a'));
            vis[node] = 2;
        }
    }

    static 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;
            }
        }
    }
    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }
    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}