Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. 

Ivan knows some information about the string s. Namely, he remembers, that string ti occurs in string s at least ki times or more, he also remembers exactly ki positions where the string ti occurs in string s: these positions are xi, 1, xi, 2, ..., xi, ki. He remembers n such strings ti.

You are to reconstruct lexicographically minimal string s such that it fits all the information Ivan remembers. Strings ti and string s consist of small English letters only.

Input

The first line contains single integer n (1 ≤ n ≤ 105) — the number of strings Ivan remembers.

The next n lines contain information about the strings. The i-th of these lines contains non-empty string ti, then positive integer ki, which equal to the number of times the string ti occurs in string s, and then ki distinct positive integers xi, 1, xi, 2, ..., xi, ki in increasing order — positions, in which occurrences of the string ti in the string s start. It is guaranteed that the sum of lengths of strings ti doesn't exceed 106, 1 ≤ xi, j ≤ 106, 1 ≤ ki ≤ 106, and the sum of all ki doesn't exceed 106. The strings ti can coincide.

It is guaranteed that the input data is not self-contradictory, and thus at least one answer always exists.

Output

Print lexicographically minimal string that fits all the information Ivan remembers. 

Examples

Input

3
a 4 1 3 5 7
ab 2 1 5
ca 1 4


Output

abacaba


Input

1
a 1 3


Output

aaa


Input

3
ab 1 1
aba 1 3
ab 2 3 5


Output

ababab
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Sol {

    static long mod = 1000000007;

    public static void main(String args[]) throws Exception {
        //Scanner in;
        InputReader in;
        PrintWriter w;
        boolean online = false;
        String fileName = "input";

        if (online) {
            //in=new Scanner(new File(fileName + ".in"));
            in = new InputReader(new FileInputStream(new File(fileName + ".in")));
            w = new PrintWriter(new FileWriter("out.txt"));
        } else {
            //in=new Scanner(System.in);
            in = new InputReader(System.in);
            w = new PrintWriter(System.out);
        }

        //int T = in.nextInt();
        //in.nextLine();
        int T = 1;

        for (int t = 1; t <= T; t++) {
            int n = in.nextInt();

            TreeMap<Integer, String> tm = new TreeMap<>();
            int size = 0;

            for (int i = 0; i < n; i++) {
                String s = in.next();

                int k = in.nextInt();

                for (int j = 0; j < k; j++) {
                    int ind = in.nextInt() - 1;

                    if (tm.containsKey(ind)) {
                        if (s.length() > tm.get(ind).length()) {
                            tm.put(ind, s);
                            size = max(size, ind + s.length());
                        }
                    } else {
                        tm.put(ind, s);
                        size = max(size, ind + s.length());
                    }
                }
            }

            char c[] = new char[size];
            Arrays.fill(c, '!');

            int ind = 0;

            for (Map.Entry m : tm.entrySet()) {
                String S = (String) m.getValue();
                int x = (int) m.getKey();

                if (x >= ind) {
                    ind = x;
                    for (int j = 0; j < S.length(); j++) {
                        c[ind++] = S.charAt(j);
                    }
                } else if (x + S.length() - 1 >= ind) {
                    for (int j = ind - x; j < S.length(); j++) {
                        c[ind++] = S.charAt(j);
                    }
                }
            }

            for (int i = 0; i < c.length; i++) {
                if (c[i] == '!') {
                    c[i] = 'a';
                }
            }

            w.println(new String(c));
        }

        w.close();
    }

    static class compare implements Comparator<pair> {

        @Override
        public int compare(pair p1, pair p2) {
            if (p1.d != p2.d) {
                return (p1.d - p2.d);
            }
            return p1.s - p2.s;
        }
    }

    static class pair implements Comparable<pair> {

        int d, t, s, ok;

        public pair(int d, int t, int s) {
            this.d = d;
            this.t = t;
            this.s = s;
            //ok = 1;
        }

        @Override
        public int compareTo(pair p) {
            if (this.s != p.s) {
                return (this.s - p.s);
            }
            if (this.d != p.d) {
                return (this.d - p.d);
            }
            return (this.t - p.t);
        }

        /*              // ************  Use only when HashMap / HashSet of pair is taken       ******************* ////////
        @Override
        public boolean equals(Object p) {
            if(p instanceof pair) {
                pair P = (pair)p;
                return this.s == P.s && this.d == P.d;
            }
            
            return false;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 79 * hash + this.d;
            //hash = 79 * hash + this.t;
            hash = 79 * hash + this.s;
            return hash;
        }*/
    }

    static int arr[];
    static int size[];

    static void initialize(int n) {
        for (int i = 0; i <= n; i++) {
            arr[i] = i;
            size[i] = 1;
        }
    }

    static int root(int r) {
        while (arr[r] != r) {
            arr[r] = arr[arr[r]];
            r = arr[r];
        }

        return r;
    }

    static void union(int u, int v) {
        int r1 = root(u);
        int r2 = root(v);

        if (r1 != r2) {
            if (size[r1] < size[r2]) {
                arr[r1] = arr[r2];
                size[r2] += size[r1];
            } else {
                arr[r2] = arr[r1];
                size[r1] += size[r2];
            }
        }
    }

    private static long gcd(long a, long b) {
        while (b > 0) {
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }

    private static long gcd(long[] input) {
        long result = input[0];

        for (int i = 1; i < input.length; i++) {
            result = gcd(result, input[i]);
        }

        return result;
    }

    private static long lcm(long a, long b) {
        return a * (b / gcd(a, b));
    }

    private static long lcm(long[] input) {
        long result = input[0];

        for (int i = 1; i < input.length; i++) {
            result = lcm(result, input[i]);
        }

        return result;
    }

    public static void Array_2dsort(Integer[][] a) {
        Arrays.sort(a, new Comparator<Integer[]>() {
            public int compare(Integer[] int1, Integer[] int2) {
                Integer numOfKeys1 = int1[1];       //about which column u want to sort
                Integer numOfKeys2 = int2[1];
                return numOfKeys1.compareTo(numOfKeys2);
            }
        });
    }

    static long powmod(long x, long n, long m) {
        if (n == 0) {
            return 1;
        } else if (n % 2 == 0) {
            return powmod(((x % m) * (x % m)) % m, n / 2, m);
        } else if (n % 2 == 1) {
            return (((x % m) * powmod(((x % m) * (x % m)) % m, (n - 1) / 2, m)) % m);
        } else {
            return 0;
        }
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c)) {
                c = read();
            }

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E') {
                        return res * Math.pow(10, nextInt());
                    }
                    if (c < '0' || c > '9') {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }

    }

}