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 CPP):

Solution:
#include <bits/stdc++.h>
using std::cerr;
using std::endl;
const int N = 1e7 + 233, M = 755;
int n, st[N], len[N], size;
char str[N], buc[N];
int ch[N][2], fail[N], tot, end[N];
std::queue<int> que;
inline void insert(int id) {
  int now = 0;
  for (int i = 1; i <= len[id]; ++i) {
    int c = str[i] - 'a';
    if (!ch[now][c]) ch[now][c] = ++tot;
    now = ch[now][c];
  }
  end[now] = id;
}
inline void build() {
  if (ch[0][0]) que.push(ch[0][0]);
  if (ch[0][1]) que.push(ch[0][1]);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = 0; i < 2; ++i) {
      if (!ch[x][i])
        ch[x][i] = ch[fail[x]][i];
      else {
        fail[ch[x][i]] = ch[fail[x]][i];
        que.push(ch[x][i]);
        if (!end[ch[x][i]]) end[ch[x][i]] = end[fail[ch[x][i]]];
      }
    }
  }
}
int G[M][M];
inline void match(char str[], int id) {
  int now = 0;
  for (int i = 1; i <= len[id]; ++i) {
    int c = str[i] - 'a';
    now = ch[now][c];
    if (end[now]) G[id][end[now]] = 1;
    if (end[fail[now]]) G[id][end[fail[now]]] = 1;
  }
}
int vis[M * 2], mat[M * 2], cnt;
int hungry(int x, int tag) {
  for (int y = 1; y <= n; ++y) {
    if (!G[x][y]) continue;
    if (vis[y + n] != tag) {
      vis[y + n] = tag;
      if (!mat[y + n] || hungry(mat[y + n], tag)) {
        mat[x] = y + n, mat[y + n] = x;
        return 1;
      }
    }
  }
  return 0;
}
int pick[M * 2];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int y = 1; y <= n; ++y)
    if (G[x][y] && !vis[y + n]) vis[y + n] = 1, dfs(mat[y + n]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str + 1);
    len[i] = strlen(str + 1);
    st[i] = size + 1;
    for (int j = 1; j <= len[i]; ++j) buc[++size] = str[j];
    insert(i);
  }
  build();
  for (int i = 1; i <= n; ++i) match(buc + st[i] - 1, i);
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) G[i][j] |= G[i][k] & G[k][j];
  for (int i = 1; i <= n; ++i) G[i][i] = 0;
  for (int i = 1; i <= n; ++i) cnt += hungry(i, i);
  printf("%d\n", n - cnt);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i)
    if (!mat[i]) dfs(i);
  for (int i = 1; i <= n; ++i)
    if (vis[i] && !vis[i + n]) printf("%d ", i);
  putchar('\n');
  return 0;
}