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;
queue<int> Q;
int ne[N][2], q[N], fail[N], pre[N], n, m, at, cnt;
int ans, lp[M], rp[M], flag1[M], flag2[M], a[M][M], flag[M], match[N], id[M];
char s[N];
void build() {
  Q.push(1);
  while (!Q.empty()) {
    int now = Q.front();
    Q.pop();
    for (int i = 0; i < 2; i++)
      if (ne[now][i]) {
        Q.push(ne[now][i]);
        if (now == 1)
          fail[ne[now][i]] = 1;
        else
          fail[ne[now][i]] = ne[fail[now]][i];
        if (!pre[ne[now][i]]) pre[ne[now][i]] = pre[fail[ne[now][i]]];
      } else {
        if (now == 1)
          ne[now][i] = 1;
        else
          ne[now][i] = ne[fail[now]][i];
      }
  }
}
int dfs(int x) {
  for (int i = 1; i <= m; i++)
    if (i != x && a[x][i] && !flag[i]) {
      flag[i] = 1;
      if (!match[i] || dfs(match[i])) {
        match[i] = x;
        return 1;
      }
    }
  return 0;
}
void dfs2(int x) {
  for (int i = 1; i <= m; i++)
    if (i != x && a[x][i] && !flag2[i]) {
      flag2[i] = 1;
      flag1[match[i]] = 0;
      dfs2(match[i]);
    }
}
int main() {
  scanf("%d", &n);
  at = 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 p = 1;
    for (int j = lp[i]; j < rp[i]; j++) {
      int x = s[j] - 'a';
      if (!ne[p][x]) ne[p][x] = ++at;
      p = ne[p][x];
    }
    if (!pre[p]) pre[p] = ++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 = ne[x][s[j] - 'a'];
      if (j != rp[id[i]] - 1)
        a[pre[x]][i] = 1;
      else
        a[pre[fail[x]]][i] = 1;
    }
    a[i][i] = 1;
  }
  for (int k = 1; k <= m; k++)
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) a[i][j] |= a[i][k] & a[k][j];
  for (int i = 1; i <= m; i++) {
    memset(flag, 0, sizeof(flag));
    ans += dfs(i);
  }
  printf("%d\n", m - ans);
  for (int i = 1; i <= m; i++) flag1[match[i]] = 1;
  for (int i = 1; i <= m; i++)
    if (!flag1[i]) dfs2(i);
  for (int i = 1; i <= m; i++)
    if (!flag1[i] && !flag2[i]) printf("%d ", id[i]);
}