Birthday

题意翻译

- 给定 $n$ 个仅包含 `a,b` 的字符串,保证它们两两不同。 - 你需要去掉尽可能少的字符串,使得剩下的字符串中不存在某一个串是另一个串的子串。 - $n \le 750$,$\sum_{i=1}^n |s_i| \le 10^7$。

题目描述

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.

输入输出格式

输入格式


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 $ 10000000 $ characters.

输出格式


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.

输入输出样例

输入样例 #1

5
abab
aba
aabab
ababb
bab

输出样例 #1

2
2 5

说明

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