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 = 1e7 + 5, M = 760;
int n, son[N][2], fail[N], id[N], p[M], cnt = 1, fa[N], f[N], m1[M], m2[M];
char s[N];
bool vis[M], vis1[M], vis2[M], e[M][M];
queue<int> q;
inline int bcj(int x) { return f[x] == x ? x : f[x] = bcj(f[x]); }
inline int find(int x) {
  if (vis[x]) return 0;
  vis[x] = 1;
  for (int i = 1; i <= n; i++)
    if (e[x][i] && (!m1[i] || find(m1[i]))) {
      m1[i] = x;
      return 1;
    }
  return 0;
}
inline void dfs(int x) {
  if (vis1[x]) return;
  vis1[x] = 1;
  for (int i = 1; i <= n; i++)
    if (e[x][i] && m2[x] != i && !vis2[i]) {
      vis2[i] = 1;
      if (m1[i]) dfs(m1[i]);
    }
  return;
}
int ans[M], siz;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    int now = 1, len = strlen(s + 1);
    for (int j = 1; j <= len; j++) {
      int c = s[j] - 'a';
      if (!son[now][c]) {
        son[now][c] = ++cnt;
        fa[cnt] = now;
      }
      now = son[now][c];
    }
    id[now] = i;
    p[i] = now;
  }
  fail[1] = 1;
  if (son[1][0]) fail[son[1][0]] = 1, q.push(son[1][0]);
  if (son[1][1]) fail[son[1][1]] = 1, q.push(son[1][1]);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (son[x][0])
      fail[son[x][0]] = son[fail[x]][0], q.push(son[x][0]);
    else
      son[x][0] = son[fail[x]][0];
    if (son[x][1])
      fail[son[x][1]] = son[fail[x]][1], q.push(son[x][1]);
    else
      son[x][1] = son[fail[x]][1];
  }
  for (int i = 1; i <= cnt; i++) f[i] = id[i] ? i : fail[i];
  for (int i = 1; i <= n; i++) {
    int x = p[i];
    int y = id[bcj(fail[x])];
    if (y) e[i][y] = 1;
    x = fa[p[i]];
    while (x) {
      if (id[x]) {
        e[i][id[x]] = 1;
        break;
      }
      if (id[bcj(x)]) e[i][id[bcj(x)]] = 1;
      x = fa[x];
    }
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) e[i][j] |= (e[i][k] && e[k][j]);
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    find(i);
  }
  for (int i = 1; i <= n; i++)
    if (m1[i]) m2[m1[i]] = i;
  for (int i = 1; i <= n; i++)
    if (!m2[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (vis1[i] && !vis2[i]) ans[++siz] = i;
  printf("%d\n", siz);
  for (int i = 1; i <= siz; i++) printf("%d ", ans[i]);
  return 0;
}