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:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {new Main().run();}

    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    void run(){
        work();
        out.flush();
    }
    long mod=1000000007;
    long gcd(long a,long b) {
        return a==0?b:gcd(b%a,a);
    }
    int[][] graph;
    int[] rec;
    int cur=1;
    void work() {
        int n=ni(),k=ni();
        rec=new int[26];
        TreeMap<Integer,List<String>> map=new TreeMap<>();
        graph=new int[26][26];
        for(int i=0;i<n;i++){
            int page=ni();
            List<String> list=new ArrayList<>();
            for(int j=0;j<k;j++){
                list.add(ns());
            }
            map.put(page,list);
        }
        List<String> list=new ArrayList<>();
        boolean[] seen=new boolean[26];
        for(int key:map.keySet()){
            List<String> l=map.get(key);
            list.addAll(l);
            for(String s:l){
                for(char c:s.toCharArray()){
                    seen[c-'a']=true;
                }
            }
        }
        for(int i=0;i<list.size()-1;i++){
            String s1=list.get(i);
            String s2=list.get(i+1);
            if(s1.length()>s2.length()&&s1.startsWith(s2)){
                out.println("IMPOSSIBLE");
                return;
            }
            for(int j=0;j<s1.length()&&j<s2.length();j++){
                char c1=s1.charAt(j),c2=s2.charAt(j);
                if(c1!=c2){
                    graph[c1-'a'][c2-'a']=1;
                    break;
                }
            }
        }
        for(int i=0;i<26;i++){
            if(seen[i]&&rec[i]==0){
                if(!dfs(i)){
                    out.println("IMPOSSIBLE");
                    return;
                }
            }
        }

        List<int[]> ret=new ArrayList<>();
        for(int i=0;i<26;i++){
            if(rec[i]>0){
                ret.add(new int[]{i,rec[i]});
            }
        }
        Collections.sort(ret,(a1,a2)->a2[1]-a1[1]);
        StringBuilder sb=new StringBuilder();
        for(int[] r:ret){
            sb.append((char)('a'+r[0]));
        }
        out.println(sb.toString());
    }

    private boolean dfs(int node) {
        if(rec[node]==-1)return false;
        rec[node]=-1;
        for(int i=0;i<26;i++){
            if(graph[node][i]==1&&i!=node&&rec[i]<=0){
                if(!dfs(i))return false;
            }
        }
        rec[node]=cur++;
        return true;
    }

    private ArrayList<long[]>[] ngw(int n, int m) {
        ArrayList<long[]>[] graph=(ArrayList<long[]>[])new ArrayList[n];
        for(int i=0;i<n;i++) {
            graph[i]=new ArrayList<>();
        }
        for(int i=1;i<=m;i++) {
            long s=in.nextLong()-1,e=in.nextLong()-1,w=in.nextLong();
            graph[(int)s].add(new long[] {e,w,i});
            graph[(int)e].add(new long[] {s,w});
        }
        return graph;
    }

    private int ni() {
        return in.nextInt();
    }

    private long nl() {
        return in.nextLong();
    }

    private String ns() {
        return in.next();
    }

    private long[] na(int n) {
        long[] A=new long[n];
        for(int i=0;i<n;i++) {
            A[i]=in.nextLong();
        }
        return A;
    }
    private int[] nia(int n) {
        int[] A=new int[n];
        for(int i=0;i<n;i++) {
            A[i]=in.nextInt();
        }
        return A;
    }
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }


    public String next()
    {
        while(st==null || !st.hasMoreElements())//回车，空行情况
        {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }
}