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, M = 10000005;
int n, ind, tox;
char s[M];
string sf[N];
int dir[M][2], fail[M], f[M], es[M], q[M], fr[2 * N], nxt[2 * N * N],
    em[2 * N * N], xm[2 * N], ym[2 * N];
bool g[N][N], vis[2 * N];
inline void addedge(int u, int v) {
  ++tox;
  nxt[tox] = fr[u];
  fr[u] = tox;
  em[tox] = v;
  ++tox;
  nxt[tox] = fr[v];
  fr[v] = tox;
  em[tox] = u;
}
inline void add(int x) {
  int l = strlen(s + 1);
  int now = 0;
  for (int i = 1; i <= l; i++) {
    if (dir[now][s[i] - 'a'] == 0) dir[now][s[i] - 'a'] = ++ind;
    now = dir[now][s[i] - 'a'];
  }
  es[now] = x;
}
void bfs() {
  int l = 0, r = 0;
  q[r++] = 0;
  while (l < r) {
    int x = q[l++];
    for (int j = 0; j <= 1; j++) {
      if (dir[x][j] == 0) continue;
      if (x == 0)
        fail[dir[x][j]] = 0;
      else {
        int k = fail[x];
        while (k != 0 && dir[k][j] == 0) k = fail[k];
        fail[dir[x][j]] = dir[k][j];
        if (es[dir[k][j]])
          f[dir[x][j]] = es[dir[k][j]];
        else
          f[dir[x][j]] = f[dir[k][j]];
      }
      q[r++] = dir[x][j];
    }
  }
}
bool find(int d) {
  for (int j = fr[d]; j != 0; j = nxt[j])
    if (vis[em[j]] == 0) {
      vis[em[j]] = 1;
      if (ym[em[j]] == -1 || find(ym[em[j]])) {
        xm[d] = em[j];
        ym[em[j]] = d;
        return true;
      }
    }
  return false;
}
inline int hungary() {
  int ans = 0;
  memset(xm, -1, sizeof(xm));
  memset(ym, -1, sizeof(ym));
  for (int i = 1; i <= n; i++)
    if (xm[i] == -1) {
      memset(vis, 0, sizeof(vis));
      if (find(i)) ans++;
    }
  return n - ans;
}
void dfs(int d) {
  vis[d] = 1;
  for (int j = fr[d]; j != 0; j = nxt[j])
    if (vis[em[j]] == 0) {
      if (d <= n && xm[d] == em[j])
        dfs(em[j]);
      else if (d > n && ym[d] != em[j])
        dfs(em[j]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    sf[i] = s + 1;
    add(i);
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    int now = 0;
    for (auto x : sf[i]) {
      now = dir[now][x - 'a'];
      if (f[now]) g[i][f[now]] = 1;
      if (es[now] != i && es[now]) g[i][es[now]] = 1;
    }
  }
  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][j] || (g[i][k] && g[k][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (g[i][j]) addedge(i, j + n);
  int ts = hungary();
  printf("%d\n", ts);
  memset(vis, 0, sizeof(vis));
  for (int i = n + 1; i <= 2 * n; i++)
    if (ym[i] == -1) {
      vis[i] = 1;
      for (int j = fr[i]; j != 0; j = nxt[j])
        if (vis[em[j]] == 0) dfs(em[j]);
    }
  for (int i = 1; i <= n; i++) vis[i] = !vis[i];
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (vis[i] && vis[i + n]) {
      ++tot;
      printf("%d%c", i, " \n"[tot == ts]);
    }
  return 0;
}