Problem: Today is birthday of a Little Dasha — she is now 8 years old! On this occasion, each of her n friends and relatives gave her a ribbon with a greeting written on it, and, as it turned out, all the greetings are different. Dasha gathered all the ribbons and decided to throw away some of them in order to make the remaining set stylish. The birthday girl considers a set of ribbons stylish if no greeting written on some ribbon is a substring of another greeting written on some other ribbon. Let us recall that the substring of the string s is a continuous segment of s.

Help Dasha to keep as many ribbons as possible, so that she could brag about them to all of her friends. Dasha cannot rotate or flip ribbons, that is, each greeting can be read in a single way given in the input.

Input

The first line of the input contains integer n (1 ≤ n ≤ 750) — the number of Dasha's relatives and friends.

Each of the next n lines contains exactly one greeting. Each greeting consists of characters 'a' and 'b' only.

The total length of all greetings won't exceed 10 000 000 characters.

Output

In the first line print the maximum size of the stylish set. In the second line print the numbers of ribbons involved in it, assuming that they are numbered from 1 to n in the order they appear in the input. If there are several stylish sets of the maximum size, print any of them.

Examples

Input

5
abab
aba
aabab
ababb
bab


Output

2
2 5

Note

In the sample, the answer that keeps ribbons 3 and 4 is also considered correct.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        int totalNode;
        int[] aNext;
        int[] bNext;
        int[] fail;
        int[] id;
        int[] nearest;
        boolean[][] g;
        BitSet[] bs;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[][] s = new char[n][];
            int totalLength = 0;
            for (int i = 0; i < n; ++i) {
                s[i] = in.next().toCharArray();
                totalLength += s[i].length;
            }
            aNext = new int[totalLength + 1];
            bNext = new int[totalLength + 1];
            id = new int[totalLength + 1];
            Arrays.fill(id, -1);
            totalNode = 1;
            for (int i = 0; i < n; ++i) {
                int crt = 0;
                for (int j = 0; j < s[i].length; ++j) {
                    int[] next = (s[i][j] == 'a' ? aNext : bNext);
                    if (next[crt] == 0) {
                        next[crt] = totalNode++;
                    }
                    crt = next[crt];
                }
                id[crt] = i;
            }

            fail = new int[totalLength + 1];
            nearest = new int[totalLength + 1];
            Arrays.fill(nearest, -1);
            int[] q = new int[totalNode];
            q[0] = 0;
            for (int h = 0, t = 1; h < t; ++h) {
                int u = q[h];
                if (id[u] >= 0) {
                    nearest[u] = id[u];
                } else {
                    nearest[u] = nearest[fail[u]];
                }
                for (int k = 0; k < 2; ++k) {
                    int[] next = (k == 0 ? aNext : bNext);
                    if (next[u] > 0) {
                        q[t++] = next[u];
                        if (u == 0) continue;
                        int j = fail[u];
                        while (j > 0 && next[j] == 0) {
                            j = fail[j];
                        }
                        if (next[j] > 0) {
                            fail[next[u]] = next[j];
                        }
                    }
                }
            }
            g = new boolean[n][n];
            for (int i = 0; i < n; ++i) {
                int crt = 0;
                for (int j = 0; j < s[i].length; ++j) {
                    int[] next = (s[i][j] == 'a' ? aNext : bNext);
                    crt = next[crt];
                    if (id[crt] == i) {
                        crt = fail[crt];
                    }
                    if (nearest[crt] >= 0) {
                        g[nearest[crt]][i] = true;
                    }
                }
            }
            bs = new BitSet[n];
            for (int i = 0; i < n; ++i) {
                bs[i] = new BitSet(n);
                for (int j = 0; j < n; ++j) {
                    if (i != j && g[j][i]) {
                        bs[i].set(j);
                    }
                }
            }
            Integer[] order = new Integer[n];
            for (int i = 0; i < n; ++i) {
                order[i] = i;
            }
            Arrays.sort(order, new Comparator<Integer>() {

                public int compare(Integer o1, Integer o2) {
                    return s[o2].length - s[o1].length;
                }
            });
            for (int i = 0; i < n; ++i) {
                int u = order[i];
                for (int j = i + 1; j < n; ++j) {
                    int v = order[j];
                    if (g[v][u]) {
                        bs[u] = bs[u].or(bs[v]);
                    }
                }
            }
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    g[i][j] = bs[i].test(j);
                }
            }
            BM sol = new BM(n, g);
            ArrayList<Integer> ans = sol.solve();
            out.println(ans.size());
            for (int i = 0; i < ans.size(); ++i) {
                out.print(ans.get(i) + 1);
                if (i + 1 == ans.size()) {
                    out.print('\n');
                } else {
                    out.print(' ');
                }
            }
        }

        class BM {
            int n;
            ArrayList<Integer>[] edg;
            boolean[] vis;
            boolean[] chs;
            int[] x;
            int[] y;
            ArrayList<Integer> ans;

            public BM(int n, boolean[][] g) {
                this.n = n;
                edg = new ArrayList[n];
                for (int i = 0; i < n; ++i) {
                    edg[i] = new ArrayList<Integer>();
                    for (int j = 0; j < n; ++j) {
                        if (g[i][j]) {
                            edg[i].add(j);
                        }
                    }
                }
                vis = new boolean[n];
                chs = new boolean[n + n];
                x = new int[n];
                y = new int[n];
                ans = new ArrayList<Integer>();
            }

            public ArrayList<Integer> solve() {
                int cnt = 0;
                Arrays.fill(x, -1);
                Arrays.fill(y, -1);
                for (int i = 0; i < n; ++i) {
                    Arrays.fill(vis, false);
                    if (dfs(i)) {
                        ++cnt;
                    }
                }
                Arrays.fill(chs, false);
                for (int i = 0; i < n; ++i) {
                    if (x[i] != -1) {
                        chs[i] = true;
                    }
                }
                Arrays.fill(vis, false);
                for (int i = 0; i < n; ++i) {
                    if (x[i] == -1 && !vis[i]) {
                        go(i);
                    }
                }
                for (int i = 0; i < n; ++i) {
                    if (!chs[i] && !chs[i + n]) {
                        ans.add(i);
                    }
                }
                if (ans.size() != n - cnt) {
                    throw new RuntimeException();
                }
                return ans;
            }

            void go(int u) {
                vis[u] = true;
                chs[u] = false;
                for (int i = 0; i < edg[u].size(); ++i) {
                    int v = edg[u].get(i);
                    chs[n + v] = true;
                    if (!vis[y[v]]) {
                        go(y[v]);
                    }
                }
            }

            boolean dfs(int u) {
                for (int i = 0; i < edg[u].size(); ++i) {
                    int v = edg[u].get(i);
                    if (!vis[v]) {
                        vis[v] = true;
                        if (y[v] == -1 || dfs(y[v])) {
                            x[u] = v;
                            y[v] = u;
                            return true;
                        }
                    }
                }
                return false;
            }

        }

    }

    static class BitSet {
        int len;
        int size;
        long[] bit;

        public BitSet(int len) {
            this.len = len;
            size = len + 63 >> 6;
            bit = new long[size];
        }

        public BitSet or(BitSet a) {
            BitSet ret = new BitSet(len);
            for (int i = 0; i < size; ++i) {
                ret.bit[i] = bit[i] | a.bit[i];
            }
            return ret;
        }

        public boolean test(int pos) {
            return (bit[pos >> 6] >> (pos & 63) & 1) > 0;
        }

        public void set(int pos) {
            bit[pos >> 6] |= 1L << (pos & 63);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}