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 MAXN = 760;
const int MAXL = 1E7 + 10;
bool vis[MAXN], tag[MAXN << 1];
char Pool[MAXL << 1], *s[MAXN], *cur = Pool;
int son[MAXL][2], fail[MAXL], rt, cnt, jmp[MAXL], ed[MAXL], n, mat[MAXN],
    matr[MAXN];
bitset<MAXN> G[MAXN];
vector<int> g[MAXN], g2[MAXN];
void insert(char *s, int id) {
  int x = rt;
  for (int i = 1; s[i]; i++) {
    if (!son[x][s[i] - 'a']) son[x][s[i] - 'a'] = ++cnt;
    x = son[x][s[i] - 'a'];
  }
  ed[x] = id;
}
void build() {
  queue<int> q;
  for (int i = 0; i < 2; i++)
    if (son[rt][i]) q.push(son[rt][i]);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    jmp[x] = ed[x] ? ed[x] : jmp[fail[x]];
    for (int i = 0; i < 2; i++)
      if (son[x][i])
        fail[son[x][i]] = son[fail[x]][i], q.push(son[x][i]);
      else
        son[x][i] = son[fail[x]][i];
  }
}
bool match(int x) {
  for (int v : g[x])
    if (!vis[v]) {
      vis[v] = 1;
      if (!mat[v] || match(mat[v])) return mat[v] = x, true;
    }
  return false;
}
void dfs(int x, int tp) {
  if (tp == 0) {
    tag[x] = 1;
    if (!tag[matr[x] + n]) dfs(matr[x], 1);
  } else {
    tag[x + n] = 1;
    for (int v : g2[x])
      if (v != mat[x] && !tag[v]) dfs(v, 0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    s[i] = cur;
    scanf("%s", s[i] + 1);
    cur += strlen(s[i] + 1) + 10;
    insert(s[i], i);
  }
  build();
  for (int i = 1; i <= n; i++) {
    int x = rt, p;
    for (int j = 1; s[i][j]; j++) {
      x = son[x][s[i][j] - 'a'], p = ed[x] == i ? fail[x] : x;
      if (jmp[p]) G[i][jmp[p]] = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (G[i][j]) G[i] |= G[j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (G[i][j] && i != j) g[i].push_back(j), g2[j].push_back(i);
  int fafa = 0;
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof vis);
    fafa += match(i);
  }
  for (int i = 1; i <= n; i++)
    if (mat[i]) matr[mat[i]] = i;
  for (int i = 1; i <= n; i++)
    if (!mat[i]) dfs(i, 1);
  int Ans = 0;
  for (int i = 1; i <= n; i++)
    if (!tag[i] && tag[i + n]) ++Ans;
  printf("%d\n", Ans);
  for (int i = 1; i <= n; i++)
    if (!tag[i] && tag[i + n]) printf("%d ", i);
  puts("");
}