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;
char s[M];
bool e[N][N];
int n;
struct ACAutomaton {
  int trie[M][2], id[M], idx, pos[M], fa[M];
  void ins(char *s, int t) {
    int cur = 0, l = strlen(s + 1);
    for (int i = 1; i <= l; i++) {
      if (!trie[cur][s[i] - 'a']) trie[cur][s[i] - 'a'] = ++idx, fa[idx] = cur;
      cur = trie[cur][s[i] - 'a'];
    }
    id[cur] = t;
    pos[t] = cur;
  }
  int fail[M];
  void build_fail() {
    queue<int> q;
    for (int i = 0; i < 2; i++)
      if (trie[0][i]) q.push(trie[0][i]);
    while (!q.empty()) {
      int nd = q.front();
      q.pop();
      for (int i = 0; i < 2; i++)
        if (trie[nd][i])
          fail[trie[nd][i]] = trie[fail[nd]][i], q.push(trie[nd][i]);
        else
          trie[nd][i] = trie[fail[nd]][i];
    }
  }
  int f[M];
  int getf(int v) { return f[v] == v ? v : f[v] = getf(f[v]); }
  void build_tr() {
    for (int i = 1; i <= idx; i++) f[i] = id[i] ? i : fail[i];
    for (int i = 1; i <= n; i++) {
      int p = pos[i];
      if (id[getf(fail[p])]) e[i][id[getf(fail[p])]] = 1;
      p = fa[pos[i]];
      while (p) {
        if (id[p]) {
          e[i][id[p]] = 1;
          break;
        }
        if (id[getf(p)]) e[i][id[getf(p)]] = 1;
        p = fa[p];
      }
    }
  }
} t;
int mat[N], mat2[N];
bool vis[N];
int find(int pos) {
  if (vis[pos]) return 0;
  vis[pos] = 1;
  for (int i = 1; i <= n; i++)
    if (e[pos][i] && (!mat[i] || find(mat[i]))) {
      mat[i] = pos;
      return 1;
    }
  return 0;
}
bool vis1[N], vis2[N];
void dfs(int pos) {
  if (vis1[pos]) return;
  vis1[pos] = 1;
  for (int i = 1; i <= n; i++)
    if (e[pos][i] && mat2[pos] != i && !vis2[i]) {
      vis2[i] = 1;
      if (mat[i]) dfs(mat[i]);
    }
}
int ans[N], idx;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> (s + 1), t.ins(s, i);
  t.build_fail();
  t.build_tr();
  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 (mat[i]) mat2[mat[i]] = i;
  for (int i = 1; i <= n; i++)
    if (!mat2[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (vis1[i] && !vis2[i]) ans[++idx] = i;
  cout << idx << endl;
  for (int i = 1; i <= idx; i++) cout << ans[i] << ' ';
  return 0;
}