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 = 2005;
int n, ch[10000005][2], tot = 1, h[N], cnt, fa[10000005], id[10000005], ans,
                        lk[N], to[N], v[N], ti, mx[N], my[N];
string s[755];
bitset<N> a[N];
struct qwe {
  int ne, to;
} e[N * N];
void add(int u, int v) {
  cnt++;
  e[cnt].ne = h[u];
  e[cnt].to = v;
  h[u] = cnt;
}
bool dfs(int u) {
  for (int i = h[u]; i; i = e[i].ne)
    if (v[e[i].to] != ti) {
      v[e[i].to] = ti;
      if (!lk[e[i].to] || dfs(lk[e[i].to])) {
        lk[e[i].to] = u, to[u] = e[i].to;
        return 1;
      }
    }
  return 0;
}
void wk(int u) {
  if (mx[u]) return;
  mx[u] = 1;
  for (int i = h[u]; i; i = e[i].ne)
    if (!my[e[i].to]) {
      my[e[i].to] = 1;
      wk(lk[e[i].to]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    int nw = 1;
    for (int j = 0; j < s[i].length(); j++) {
      if (!ch[nw][s[i][j] - 'a']) ch[nw][s[i][j] - 'a'] = ++tot;
      nw = ch[nw][s[i][j] - 'a'];
    }
    id[nw] = i;
  }
  queue<int> q;
  for (int i = 0; i < 2; i++) {
    if (ch[1][i])
      fa[ch[1][i]] = 1, q.push(ch[1][i]);
    else
      ch[1][i] = 1;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 2; i++) {
      if (ch[u][i]) {
        fa[ch[u][i]] = ch[fa[u]][i];
        q.push(ch[u][i]);
        if (!id[ch[u][i]]) id[ch[u][i]] = id[fa[ch[u][i]]];
      } else
        ch[u][i] = ch[fa[u]][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    int nw = 1;
    for (int j = 0; j < s[i].length(); j++) {
      nw = ch[nw][s[i][j] - 'a'];
      if (id[nw] && id[nw] != i) a[i][id[nw]] = 1;
      if (id[fa[nw]] && id[fa[nw]]) a[i][id[fa[nw]]] = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[j][i]) a[j] |= a[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j && a[i][j]) add(i, j);
  for (int i = 1; i <= n; i++) {
    ti++;
    if (dfs(i)) ans++;
  }
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; i++)
    if (!to[i]) wk(i);
  for (int i = 1; i <= n; i++)
    if (mx[i] && !my[i]) printf("%d ", i);
  return 0;
}