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