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 read() {
  int a = 0, fh = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a * fh;
}
int n;
int add[10000005][2], cnt = 0;
int tag[10000005];
string s[755];
void ins(int id, string s) {
  int now = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (!add[now][s[i] - 'a']) add[now][s[i] - 'a'] = ++cnt;
    now = add[now][s[i] - 'a'];
  }
  tag[now] = id;
}
int q[10000005], fail[10000005], fa[10000005];
int G[755][755];
int mat[755 << 1], vis[755 << 1], ans;
void getfail() {
  int l = 1, r = 0;
  for (int i = 0; i < 2; ++i)
    if (add[0][i]) q[++r] = add[0][i];
  while (l <= r) {
    int first = q[l++];
    fa[first] = tag[fail[first]] ? fail[first] : fa[fail[first]];
    for (int i = 0; i < 2; ++i)
      if (!add[first][i])
        add[first][i] = add[fail[first]][i];
      else {
        q[++r] = add[first][i];
        fail[add[first][i]] = add[fail[first]][i];
      }
  }
}
bool dfs(int first) {
  if (vis[first]) return 0;
  vis[first] = 1;
  for (int i = 1; i <= n; ++i) {
    if (i == first) continue;
    if (G[first][i]) {
      if (!mat[i + n]) {
        mat[first] = i + n;
        mat[i + n] = first;
        ans++;
        return 1;
      } else {
        int v = mat[i + n];
        mat[first] = i + n;
        mat[i + n] = first;
        mat[v] = 0;
        if (dfs(v)) return 1;
        mat[first] = 0;
        mat[i + n] = v;
        mat[v] = i + n;
      }
    }
  }
  return 0;
}
void DFS(int first) {
  if (vis[first]) return;
  vis[first] = 1;
  for (int i = 1; i <= n; ++i) {
    if (G[first][i] && first != i) {
      vis[i + n] = 1;
      DFS(mat[i + n]);
    }
  }
}
signed main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    ins(i, s[i]);
  }
  getfail();
  for (int i = 1; i <= n; ++i) {
    int now = 0;
    for (int j = 0; j < s[i].size(); ++j) {
      now = add[now][s[i][j] - 'a'];
      G[i][tag[now]] = 1;
      G[i][tag[fa[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] = max(G[i][j], min(G[i][k], G[k][j]));
  for (int i = 1; i <= n; ++i) {
    dfs(i);
    for (int j = 1; j <= n; ++j) vis[j] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (!mat[i]) DFS(i);
  }
  cout << n - ans << endl;
  for (int i = 1; i <= n; ++i) {
    if (vis[i] && (!vis[i + n])) cout << i << " ";
  }
  return 0;
}