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

public class E {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	int[] cA, cB; // 80 mb
	int[] sufLink; // 40 mb
	int[] goA, goB; // 80 mb
	int[] which; // 40 mb
	int[] first; // 40 mb

	int size = 1;

	int add(String s, int id) {
		int v = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int[] tr = c == 'a' ? cA : cB;
			if (tr[v] == -1) {
				tr[v] = size++;
			}
			v = tr[v];
		}
		which[v] = id;
		return v;
	}

	int[] pair1, pair2;
	boolean[] used1;
	boolean[] used2;
	boolean[][] g;

	int n;

	boolean dfs(int v) {
		used1[v] = true;
		for (int u = 0; u < n; u++) {
			if (!g[v][u]) {
				continue;
			}
			if (pair2[u] == -1 || (!used1[pair2[u]] && dfs(pair2[u]))) {
				pair1[v] = u;
				pair2[u] = v;
				return true;
			}
		}
		return false;
	}
	
	void dfs2(int v) {
		used1[v] = true;
		for (int u = 0; u < n; u++) {
			if (!g[v][u] || pair1[v] == u) {
				continue;
			}
			used2[u] = true;
			if (!used1[pair2[u]]) {
				dfs2(pair2[u]);
			}
		}
	}

	void solve() throws IOException {
		n = nextInt();
		String[] s = new String[n]; // 20 mb

		int maxSize = 1;

		for (int i = 0; i < n; i++) {
			s[i] = nextToken();
			maxSize += s[i].length();
		}

		cA = new int[maxSize];
		cB = new int[maxSize];
		sufLink = new int[maxSize];
		goA = new int[maxSize];
		goB = new int[maxSize];
		which = new int[maxSize];
		first = new int[maxSize];
		Arrays.fill(cA, -1);
		Arrays.fill(cB, -1);
		Arrays.fill(which, -1);

		int[] ends = new int[n];
		for (int i = 0; i < n; i++) {
			ends[i] = add(s[i], i);
		}

		int[] q = new int[size]; // 10 mb
		int qHead = 0;
		int qTail = 0;

		sufLink[0] = 0;
		goA[0] = cA[0] == -1 ? 0 : cA[0];
		goB[0] = cB[0] == -1 ? 0 : cB[0];
		first[0] = -1;

		if (cA[0] != -1) {
			sufLink[cA[0]] = 0;
			q[qTail++] = cA[0];
		}

		if (cB[0] != -1) {
			sufLink[cB[0]] = 0;
			q[qTail++] = cB[0];
		}

		while (qHead < qTail) {
			int v = q[qHead++];
			int suf = sufLink[v];
			if (v != 0) {
				goA[v] = cA[v] != -1 ? cA[v] : goA[suf];
				goB[v] = cB[v] != -1 ? cB[v] : goB[suf];
				first[v] = which[v] != -1 ? which[v] : first[suf];
			}

			if (cA[v] != -1) {
				sufLink[cA[v]] = goA[suf];
				q[qTail++] = cA[v];
			}

			if (cB[v] != -1) {
				sufLink[cB[v]] = goB[suf];
				q[qTail++] = cB[v];
			}
		}

		g = new boolean[n][n];
		for (int i = 0; i < n; i++) {
			int v = 0;
			String cur = s[i];
			for (int j = 0; j < cur.length(); j++) {
				v = cur.charAt(j) == 'a' ? cA[v] : cB[v];
				if (first[v] == i) {
					if (first[sufLink[v]] != -1) {
						g[i][first[sufLink[v]]] = true;
					}
				} else if (first[v] != -1) {
					g[i][first[v]] = true;
				}
			}
		}

		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					g[i][j] |= g[i][k] && g[k][j];
				}
		
//		for (int i = 0; i < n; i++)
//			for (int j = 0; j < n; j++) {
//				if (i != j && (s[i].indexOf(s[j]) != -1) != g[i][j]) {
//					throw new AssertionError();
//				}
//			}

		pair1 = new int[n];
		pair2 = new int[n];
		used1 = new boolean[n];
		used2 = new boolean[n];
		Arrays.fill(pair1, -1);
		Arrays.fill(pair2, -1);

		int ans = n;

		for (int i = 0; i < n; i++) {
			Arrays.fill(used1, false);
			if (dfs(i)) {
				ans--;
			}
		}
		
		Arrays.fill(used1, false);
		out.println(ans);
		for (int i = 0; i < n; i++) {
			if (pair1[i] == -1) {
				dfs2(i);
			}
		}
		
		
		
		for (int i = 0; i < n; i++) {
			if (used1[i] && !used2[i]) {
				out.print((i + 1) + " ");
			}
		}
		out.println();
	}

	E() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new E();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}