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.FileInputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Optional;

public class Main
{
    static class Scan
    {
        final private int BUF_SIZE = 1 << 16;
        private int cur_size = 0;
        private int pointer = 0;
        private java.io.DataInputStream in;
        private byte buffer[] = new byte[BUF_SIZE];

        Scan(java.io.InputStream input)
        {
            in = new java.io.DataInputStream(input);
        }

        // fills the buffer with characters
        private void fill() throws java.io.IOException
        {
            cur_size = in.read(buffer, 0, BUF_SIZE);
            if (cur_size == -1) buffer[0] = 0;
            pointer = 0;
        }

        private byte read() throws java.io.IOException
        {
            if (pointer == cur_size) fill();
            return buffer[pointer++];
        }

        int readInt() throws java.io.IOException
        {
            int res = 0;
            byte c;
            while ((c = read()) <= ' ');
            boolean negate = c == '-';
            if (negate) c = read();
            while (c >= '0' && c <= '9')
            {
                res = res * 10 + c - '0';
                c = read();
            }
            return negate ? -res : res;
        }

        long readLong() throws java.io.IOException
        {
            long res = 0;
            byte c;
            while ((c = read()) <= ' ') ;
            boolean negate = c == '-';
            if (negate) c = read();
            while (c >= '0' && c <= '9') {
                res = res * 10 + c - '0';
                c = read();
            }
            return negate ? -res : res;
        }

        double readDouble() throws java.io.IOException
        {
            byte c;
            while ((c = read()) <= ' ');
            boolean negate = c == '-';
            if (negate)
                c = read();
            int power = 0;
            long res = 0;
            boolean dot_flag = false;
            for (;(c >= '0' && c <= '9') || c == '.'; c = read())
            {
                if (dot_flag)
                    power++;
                if (c == '.')
                    dot_flag = true;
                else
                    res = res * 10 + c - '0';
            }
            double ret = res / Math.pow(10, power);
            return negate ? -ret : ret;
        }

        // skip defines whether ' ', '\n', '\r' must be skipped in readChar method
        char readChar(boolean skip) throws java.io.IOException
        {
            if (skip)
            {
                byte c;
                while ((c = read()) == ' ' || c == '\n' || c == '\r');
                return (char) c;
            }
            return (char) read();
        }

        // skip defines whether current string must be skipped in readString and readText methods

        /* If exact length is known, in terms of efficiency
         it is better to specify it while using readText, readString and readWord methods */

        String readWord() throws java.io.IOException
        {
            byte c;
            while ((c = read()) == '\n' || c == ' ' || c == '\r');
            StringBuilder s = new StringBuilder();
            s.append((char)c);
            for (;(c = read()) != '\n' && c != ' ' && c != '\r' && c != 0; s.append((char)c));
            return s.toString();
        }

        String readWord(int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            while ((c = read()) == '\n' || c == ' ' || c == '\r');
            s[0] = c;
            for (int i = 1; (c = read()) != ' ' && c != '\n' && c != '\r' && c != 0; s[i++] = c);
            return new String(s);
        }

        String readString(boolean skip, int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (int i = 0; (c = read()) != '\n' && c != '\r' && c != 0; s[i++] = c);
            read();
            return new String(s);
        }

        String readString(boolean skip) throws java.io.IOException
        {
            StringBuilder s = new StringBuilder("");
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (;(c = read()) != '\n' && c != '\r' && c != 0; s.append((char)c));
            read();
            return s.toString();
        }

        String readText(boolean skip, int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (int i = 0; (c = read()) != 0; s[i++] = c);
            return new String(s);
        }

        String readText(boolean skip) throws java.io.IOException
        {
            StringBuilder s = new StringBuilder("");
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (;(c = read()) != 0; s.append((char)c));
            return s.toString();
        }
    }

    static class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2>> implements Comparable<Pair<T1, T2>>
    {
        T1 left;
        T2 right;

        Pair(T1 l, T2 r)
        {
            left = l;
            right = r;
        }

        public String toString()
        {
            return left + " " + right;
        }

        public int compareTo(Main.Pair<T1, T2> e)
        {
            if (left.compareTo(e.left) > 0) return 1;
            if (left.compareTo(e.left) < 0) return -1;
            if (right.compareTo(e.right) > 0) return 1;
            if (right.compareTo(e.right) < 0) return -1;
            return 0;
        }

        public int hashCode()
        {
            return (int)((left.hashCode() * (Integer.MAX_VALUE + 1L) + right.hashCode()) % Integer.MAX_VALUE);
        }

        public boolean equals(Object o)
        {
            return (o instanceof Pair) && (((Pair) o).left == this.left) && (((Pair) o).right == this.right);
        }
    }

    static class Triplet<T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>>
            implements Comparable<Triplet<T1, T2, T3>>
    {
        private T1 left;
        private T2 mid;
        private T3 right;

        Triplet(T1 l, T2 m, T3 r)
        {
            left = l;
            mid = m;
            right = r;
        }

        T1 getLeft()
        {
            return left;
        }

        T2 getMid()
        {
            return mid;
        }

        T3 getRight()
        {
            return right;
        }

        public int compareTo(Triplet<T1, T2, T3> e)
        {
            if (left.compareTo(e.getLeft()) > 0) return 1;
            if (left.compareTo(e.getLeft()) < 0) return -1;
            if (mid.compareTo(e.getMid()) > 0) return 1;
            if (mid.compareTo(e.getMid()) < 0) return -1;
            if (right.compareTo(e.getRight()) > 0) return 1;
            if (right.compareTo(e.getRight()) < 0) return -1;
            return 0;
        }

        public String toString()
        {
            return left + " " + mid + " " + right;
        }
    }

    public static void main(String[] args) throws Exception
    {
        try (PrintWriter out = new PrintWriter(System.out))
        {
            Scan in = new Scan(System.in);
            int n = in.readInt();
            int str[] = new int[1000000];
            String data[] = new String[n];
            Arrays.fill(str, -1);
            for (int i = 0; i < n; i++)
            {
                data[i] = in.readWord();
                int k = in.readInt();
                for (int j = 0; j < k; j++)
                {
                    int ind = in.readInt() - 1;
                    if (str[ind] == -1 || data[str[ind]].length() < data[i].length())
                        str[ind] = i;
                }
            }
            int len = -1;
            for (int i = 0; i < 1000000; i++)
                if (str[i] != -1)
                    len = Math.max(len, i + data[str[i]].length());
            Optional<String> s = Optional.empty();
            int p = 0;
            for (int i = 0; i < len; i++)
            {
                if (i < 1000000 && str[i] != -1 && (!s.isPresent() || s.get().length() - p < data[str[i]].length()))
                {
                    p = 1;
                    s = Optional.of(data[str[i]]);
                    out.print(s.get().charAt(0));
                }
                else if (!s.isPresent() || p >= s.get().length())
                    out.print('a');
                else
                {
                    out.print(s.get().charAt(p));
                    p++;
                }
            }
        }
    }
}
