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 cf327E {

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

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

	int size = 2;

	int add(char[] s, int id) {
		int v = 1;
		for (int i = 0; i < s.length; i++) {
			char c = s[i];
			int[] tr = c == 'a' ? goA : goB;
			if (tr[v] == 0) {
				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();
		char[][] s = new char[n][]; // 20 mb

		int maxSize = 2;

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

		goA = new int[maxSize];
		goB = new int[maxSize];
		sufLink = new int[maxSize];
		which = new int[maxSize];
		Arrays.fill(which, -1);
		
		for (int i = 0; i < n; i++) {
			add(s[i], i);
		}

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

		sufLink[1] = 0;
		goA[0] = goB[0] = 1;

		q[qTail++] = 1;

		while (qHead < qTail) {
			int v = q[qHead++];
			int suf = sufLink[v];
			
			if (which[v] == -1) {
				which[v] = which[suf];
			}
			
			for (int i = 0; i < 2; i++) {
				int[] go = i == 0 ? goA : goB;
				if (go[v] == 0) {
					go[v] = go[suf];
				} else {
					int to = go[v];
					sufLink[to] = go[suf];
					q[qTail++] = to;
				}
			}
			
		}

		g = new boolean[n][n];
		for (int i = 0; i < n; i++) {
			int v = 1;
			char[] cur = s[i];
			for (int j = 0; j < cur.length; j++) {
				v = cur[j] == 'a' ? goA[v] : goB[v];
				if (j == cur.length - 1) {
					if (which[sufLink[v]] != -1) {
						g[i][which[sufLink[v]]] = true;
					}
				} else if (which[v] != -1) {
					g[i][which[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];
				}
		
		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();
	}

	cf327E() 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 cf327E();
	}

	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());
	}
}