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 = 755;
const int M = 10000005;
const int inf = 1e9;
const long long Inf = 1e10;
const int P = 1000000007;
int tre[M][2], n, cnt = 1, don[N];
bitset<N> G[N];
int en[M], fa[M], ne[M], S[M], st[N], ed[N], len;
int Q[M], r;
int DFS(int x) {
  if (en[x]) return en[x];
  if (ne[x]) return ne[x];
  return ne[x] = DFS(fa[x]);
}
void ACbuild() {
  for (int i = (int)(0); i < (int)(2); i++)
    if (!tre[1][i])
      tre[1][i] = 1;
    else
      fa[Q[++r] = tre[1][i]] = 1;
  for (int i = (int)(1); i <= (int)(r); i++) {
    int u = Q[i];
    for (int j = (int)(0); j < (int)(2); j++) {
      int &v = tre[u][j];
      if (v)
        fa[Q[++r] = v] = tre[fa[u]][j];
      else
        v = tre[fa[u]][j];
    }
  }
  ne[1] = -1;
  for (int i = (int)(2); i <= (int)(r); i++) {
    int u = Q[i];
    ne[u] = DFS(fa[u]);
  }
}
void work(int x) {
  if (don[x]) return;
  don[x] = 1;
  if (x == 5) x = 5;
  for (int y = (int)(st[x]); y <= (int)(ed[x]); y++) {
    int u = S[y];
    if (en[u] && en[u] != x) G[x][en[u]] = 1;
    int p = ne[u];
    if (p >= 0) {
      work(p);
      G[x] |= G[p];
      G[x][p] = 1;
    }
  }
}
int mat[N], vis[N], Vis[N];
int Do(int x) {
  if (!x) return 1;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (G[x][i]) {
      if (vis[i]) continue;
      vis[i] = 1;
      if (Do(mat[i])) {
        mat[i] = x;
        return 1;
      }
    }
  return 0;
}
int V[N][2], F[N];
void dfs(int x, int y) {
  if (V[x][y]) return;
  V[x][y] = 1;
  for (int i = (int)(1); i <= (int)(n); i++) {
    if (!y && G[x][i]) dfs(i, 1);
    if (y && mat[x] == i) dfs(i, 0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    char ch = getchar();
    int p = 1;
    st[i] = len + 1;
    while (ch < 'a' || ch > 'b') ch = getchar();
    while (ch >= 'a' && ch <= 'b') {
      int x = ch - 'a';
      int &v = tre[p][x];
      if (!v) v = ++cnt;
      p = v;
      S[++len] = p;
      ch = getchar();
    }
    ed[i] = len, en[p] = i;
  }
  ACbuild();
  for (int i = (int)(1); i <= (int)(n); i++) work(i);
  int ans = n;
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (int j = (int)(1); j <= (int)(n); j++) vis[j] = 0;
    if (Do(i)) {
      F[i] = 1;
      ans--;
    }
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    if (!F[i]) dfs(i, 0);
  for (int i = (int)(1); i <= (int)(n); i++) {
    if (F[i] && !V[i][0]) Vis[i] = 1;
    if (mat[i] && V[i][1]) Vis[i] = 1;
  }
  printf("%d\n", ans);
  for (int i = (int)(1); i <= (int)(n); i++)
    if (!Vis[i]) printf("%d ", i);
  return 0;
}