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>
int ch[10000005][2], q[10000005];
int fail[10000005], pre[10000005];
int n, m, tot, cnt, ans;
char s[10000005];
int lp[755], rp[755], ul[755], ur[755];
int to[755][755], vis[755], from[10000005];
int id[755];
void build() {
  int h = 0, t = 1;
  q[1] = 1;
  int i;
  while (h != t) {
    int x = q[++h];
    for (i = 0; i < 2; i++)
      if (ch[x][i]) {
        q[++t] = ch[x][i];
        if (x == 1)
          fail[ch[x][i]] = 1;
        else
          fail[ch[x][i]] = ch[fail[x]][i];
        if (!pre[ch[x][i]]) pre[ch[x][i]] = pre[fail[ch[x][i]]];
      } else {
        if (x == 1)
          ch[x][i] = 1;
        else
          ch[x][i] = ch[fail[x]][i];
      }
  }
}
int dfs(int x) {
  int i;
  for (i = 1; i <= m; i++)
    if (i != x && to[x][i] && !vis[i]) {
      vis[i] = 1;
      if (!from[i] || dfs(from[i])) {
        from[i] = x;
        return 1;
      }
    }
  return 0;
}
void dfs2(int x) {
  int i;
  for (i = 1; i <= m; i++)
    if (i != x && to[x][i] && !ur[i]) {
      ur[i] = 1;
      ul[from[i]] = 0;
      dfs2(from[i]);
    }
}
int main() {
  scanf("%d", &n);
  tot = 1;
  int i, j;
  for (i = 1; i <= n; i++) {
    lp[i] = rp[i - 1];
    scanf("%s", s + lp[i]);
    rp[i] = strlen(s + lp[i]) + lp[i];
    int x = 1;
    for (j = lp[i]; j < rp[i]; j++) {
      int tmp = s[j] - 'a';
      if (!ch[x][tmp]) ch[x][tmp] = ++tot;
      x = ch[x][tmp];
    }
    if (!pre[x]) pre[x] = ++m, id[m] = i;
  }
  build();
  for (i = 1; i <= m; i++) {
    int x = 1;
    for (j = lp[id[i]]; j < rp[id[i]]; j++) {
      x = ch[x][s[j] - 'a'];
      if (j != rp[id[i]] - 1)
        to[pre[x]][i] = 1;
      else
        to[pre[fail[x]]][i] = 1;
    }
    to[i][i] = 1;
  }
  int k;
  for (k = 1; k <= m; k++)
    for (i = 1; i <= m; i++)
      for (j = 1; j <= m; j++) to[i][j] |= to[i][k] & to[k][j];
  for (i = 1; i <= m; i++) {
    memset(vis, 0, sizeof(vis));
    ans += dfs(i);
  }
  printf("%d\n", m - ans);
  for (i = 1; i <= m; i++) {
    ul[from[i]] = 1;
  }
  for (i = 1; i <= m; i++) {
    if (!ul[i]) dfs2(i);
  }
  for (i = 1; i <= m; i++) {
    if (!ul[i] && !ur[i]) {
      printf("%d ", id[i]);
    }
  }
}