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

public class E {
	FastScanner in;
	PrintWriter out;

	class AhoCorasick {
		int[][] g;
		int[] link;
		int[] term;
		int[] linkTerm;
		char[][] c;
		int size;
		int free;
		int countLetters;

		public AhoCorasick(char[][] c, int alphabet) {
			this.c = c;
			countLetters = alphabet;
			free = size = 1;
			for (char[] cc : c) {
				size += cc.length;
			}
			g = new int[countLetters][size];
			term = new int[size];
			link = new int[size];
			linkTerm = new int[size];
			for (int[] gg : g) {
				Arrays.fill(gg, -1);
			}
			Arrays.fill(term, -1);
			Arrays.fill(link, -1);
			Arrays.fill(linkTerm, -1);
			for (int i = 0; i < c.length; i++) {
				add(c[i], i);
			}
			buildLink();
		}

		void add(char[] s, int id) {
			int v = 0;
			for (int i = 0; i < s.length; i++) {
				if (g[s[i]][v] == -1) {
					g[s[i]][v] = free++;
				}
				v = g[s[i]][v];
			}
			term[v] = id;
		}

		void buildLink() {
			int[] q = new int[size];
			int st = 0, en = 0;
			q[en++] = 0;
			while (st != en) {
				int v = q[st++];
				for (int i = 0; i < countLetters; i++) {
					int u = g[i][v];
					int w = (link[v] == -1) ? 0 : g[i][link[v]];
					if (u == -1) {
						g[i][v] = w;
					} else {
						link[u] = w;
						q[en++] = u;
					}
				}
				if (v != 0) {
					linkTerm[v] = (term[v] != -1) ? term[v] : linkTerm[link[v]];
				}
			}
		}
		
		void buildGraph(boolean[][] a) {
			for (int i = 0; i < c.length; i++) {
				char[] s = c[i];
				int v = 0;
				for (int j = 0; j < s.length; j++) {
					v = g[s[j]][v];
					int u = linkTerm[v];
					if (j + 1 == s.length) {
						u = linkTerm[link[v]];
					}
					if (u != -1) {
						a[i][u] = true;
					}
				}
			}
		}
		
		void print() {
			for (int i = 0; i < free; i++) {
				out.println("link " + i + " = " + link[i]);
				for (int j = 0; j < countLetters; j++) {
					out.println(i + " " + j + " -> " + g[j][i]);
				}
			}
		}
	}
	
	boolean[][] g;
	int[] mt;
	boolean[] used;
	boolean[] lPlus;
	boolean[] rPlus;
	
	void dfs(int v) {
		if (lPlus[v]) {
			return;
		}
		lPlus[v] = true;
		for (int u = 0; u < g[v].length; u++) {
			if (g[v][u] && mt[u] != v) {
				rPlus[u] = true;
				dfs(mt[u]);
			}
		}
	}
	
	boolean tryKuhn(int v) {
		if (used[v]) {
			return false;
		}
		used[v] = true;
		for (int u = 0; u < g[v].length; u++) {
			if (g[v][u]) {
				if (mt[u] == -1 || tryKuhn(mt[u])) {
					mt[u] = v;
					return true;
				}
			}
		}
		return false;
	}
	
	public void solve() throws IOException {
		int n = in.nextInt();
		char[][] c = new char[n][];
		for (int i = 0; i < n; i++) {
			c[i] = in.next().toCharArray();
			for (int j = 0; j < c[i].length; j++) {
				c[i][j] -= 'a';
			}
		}
		AhoCorasick ac = new AhoCorasick(c, 2);
		g = new boolean[n][n];
		ac.buildGraph(g);
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (g[i][k] && g[k][j]) {
						g[i][j] = true;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < c[i].length; j++) {
				c[i][j] += 'a';
			}
		}
		/*for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (g[i][j] && i != j) {
					System.out.println(new String(c[i]) + " contains " + new String(c[j]));
				}
			}
		}*/
		mt = new int[n];
		boolean[] matched = new boolean[n];
		used = new boolean[n];
		lPlus = new boolean[n];
		rPlus = new boolean[n];
		Arrays.fill(mt, -1);
		int size = 0;
		for (int v = 0; v < n; v++) {
			Arrays.fill(used, false);
			matched[v] = tryKuhn(v);
			if (matched[v]) {
				size++;
			}
		}
		for (int v = 0; v < n; v++) {
			if (!matched[v]) {
				dfs(v);
			}
		}
		boolean[] coverSet = new boolean[n];
		ArrayList<Integer> ans = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			coverSet[i] = !lPlus[i] || rPlus[i];
			if (!coverSet[i]) {
				ans.add(i);
			}
		}
		out.println(ans.size());
		for (int x : ans) {
			out.print((x + 1) + " ");
		}
	}

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

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new E().run();
	}
}