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;
int g[760][760], n, cc, f[10000010], t[10000010][2], ed[10000010], po[760],
    ff[10000010], vi[760], v1[760], v2[760], mt[760], fa[10000010], m2[760], ct,
    ans[760];
char s[10000010];
int st[10000010], cg;
int fd(int x) {
  while (f[x] != x) {
    st[++cg] = x;
    x = f[x];
  }
  while (cg) {
    f[st[cg]] = x;
    cg--;
  }
  return x;
}
void ins(char *s, int i) {
  int x = 1;
  for (int i = 0; s[i]; i++) {
    if (!t[x][s[i] - 'a']) {
      t[x][s[i] - 'a'] = ++cc;
      ff[cc] = x;
    }
    x = t[x][s[i] - 'a'];
  }
  ed[x] = i;
  po[i] = x;
}
void bd() {
  queue<int> q;
  fa[1] = 1;
  for (int i = 0; i < 2; i++)
    if (t[1][i]) {
      q.push(t[1][i]);
      fa[t[1][i]] = 1;
    }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < 2; i++) {
      if (t[x][i]) {
        fa[t[x][i]] = t[fa[x]][i];
        q.push(t[x][i]);
      } else
        t[x][i] = t[fa[x]][i];
    }
  }
}
int fv(int x) {
  if (vi[x]) return 0;
  vi[x] = 1;
  for (int i = 1; i <= n; i++)
    if (g[x][i])
      if (!mt[i] || fv(mt[i])) {
        mt[i] = x;
        return 1;
      }
  return 0;
}
void fz(int x) {
  if (v1[x]) return;
  v1[x] = 1;
  for (int i = 1; i <= n; i++)
    if (g[x][i] && m2[x] != i && !v2[i]) {
      v2[i] = 1;
      if (mt[i]) fz(mt[i]);
    }
}
int main() {
  cc = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    ins(s, i);
  }
  bd();
  for (int i = 1; i <= cc; i++) {
    if (ed[i])
      f[i] = i;
    else
      f[i] = fa[i];
  }
  for (int i = 1; i <= n; i++) {
    int x = po[i];
    if (ed[fd(fa[x])]) g[i][ed[fd(fa[x])]] = 1;
    x = ff[po[i]];
    while (x) {
      if (ed[x]) {
        g[i][ed[x]] = 1;
        break;
      }
      if (ed[fd(x)]) g[i][ed[fd(x)]] = 1;
      x = ff[x];
    }
  }
  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++) {
    memset(vi, 0, sizeof(vi));
    fv(i);
  }
  for (int i = 1; i <= n; i++)
    if (mt[i]) m2[mt[i]] = i;
  for (int i = 1; i <= n; i++)
    if (!m2[i]) fz(i);
  for (int i = 1; i <= n; i++)
    if (v1[i] && !v2[i]) ans[++ct] = i;
  printf("%d\n", ct);
  for (int i = 1; i <= ct; i++) printf("%d ", ans[i]);
}