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>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
namespace ywy {
bitset<800> v[800];
vector<char> vec[800];
int que[10000001];
int trie[10000001][2], f[10000001], fail[10000001], id[2001];
typedef struct _b {
  int dest;
  int nxt;
  int c;
} bian;
bian memchi[1000001];
int gn = 2, heads[2001];
inline void add(int s, int t, int c) {
  memchi[gn].dest = t;
  memchi[gn].c = c;
  memchi[gn].nxt = heads[s];
  heads[s] = gn;
  gn++;
}
int s, t;
inline int bfs() {
  memset(id, 0, sizeof(id));
  int head = 0, tail = 1;
  id[t] = 1234567890;
  que[0] = t;
  do {
    int me = que[head];
    head++;
    for (register int i = heads[me]; i; i = memchi[i].nxt) {
      if (!memchi[i ^ 1].c || id[memchi[i].dest]) continue;
      id[memchi[i].dest] = id[me] - 1;
      if (memchi[i].dest == s) return (1);
      que[tail] = memchi[i].dest;
      tail++;
    }
  } while (head < tail);
  return (0);
}
int dfs(int pt, int flow) {
  if (pt == t) return (flow);
  int rest = flow;
  for (register int i = heads[pt]; i && rest; i = memchi[i].nxt) {
    if (!memchi[i].c || id[memchi[i].dest] != id[pt] + 1) continue;
    int cjr = dfs(memchi[i].dest, min(memchi[i].c, rest));
    if (!cjr) id[memchi[i].dest] = 0;
    memchi[i].c -= cjr;
    memchi[i ^ 1].c += cjr;
    rest -= cjr;
  }
  return (flow - rest);
}
char str[10000011];
inline int sget() {
  char c;
  int ptr = 1;
  while ((c = getchar()) || 23333)
    if (c >= 'a' && c <= 'z') break;
  str[ptr] = c;
  ptr++;
  while ((c = getchar()) || 23333) {
    if (c >= 'a' && c <= 'z')
      str[ptr] = c, ptr++;
    else
      return (ptr - 1);
  }
}
unsigned char bv[2001];
int addr[10000001];
void ywymain() {
  int n;
  cin >> n;
  int gac = 1;
  for (register int i = 1; i <= n; i++) {
    int len = sget();
    int cur = 0;
    for (register int j = 1; j <= len; j++) {
      vec[i].push_back(str[j] - 'a');
      if (!trie[cur][str[j] - 'a']) trie[cur][str[j] - 'a'] = gac, gac++;
      cur = trie[cur][str[j] - 'a'];
    }
    addr[cur] = i;
  }
  int head = 0, tail = 0;
  for (register int i = 0; i <= 1; i++)
    if (trie[0][i]) que[tail] = trie[0][i], tail++;
  while (head < tail) {
    int me = que[head];
    head++;
    for (register int i = 0; i <= 1; i++) {
      if (trie[me][i]) {
        fail[trie[me][i]] = trie[fail[me]][i];
        if (addr[fail[trie[me][i]]])
          f[trie[me][i]] = addr[fail[trie[me][i]]];
        else
          f[trie[me][i]] = f[fail[trie[me][i]]];
        que[tail] = trie[me][i];
        tail++;
      } else
        trie[me][i] = trie[fail[me]][i];
    }
  }
  s = n * 2 + 1;
  t = s + 1;
  for (register int i = 1; i <= n; i++) {
    add(s, i, 1);
    add(i, s, 0);
    add(i + n, t, 1);
    add(t, i + n, 0);
    int cur = 0;
    for (register int j = 0; j < vec[i].size(); j++) {
      cur = trie[cur][vec[i][j]];
      if (j != vec[i].size() - 1) {
        if (addr[cur])
          v[i][addr[cur]] = 1;
        else {
          if (f[cur]) v[i][f[cur]] = 1;
        }
      } else {
        if (f[cur]) v[i][f[cur]] = 1;
      }
    }
  }
  for (register int k = 1; k <= n; k++) {
    for (register int i = 1; i <= n; i++) {
      if (!v[i][k]) continue;
      v[i] |= v[k];
    }
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= n; j++)
      if (v[i][j] && i != j) add(i, j + n, 1234567890), add(j + n, i, 0);
  }
  int ans = n;
  while (bfs()) {
    while (1) {
      int cjr = dfs(s, 1234567890);
      if (!cjr) break;
      ans -= cjr;
    }
  }
  cout << ans << endl;
  bv[s] = 1;
  head = 0;
  tail = 1;
  que[0] = s;
  do {
    int me = que[head];
    head++;
    for (register int i = heads[me]; i; i = memchi[i].nxt) {
      if (!memchi[i].c || bv[memchi[i].dest]) continue;
      bv[memchi[i].dest] = 1;
      que[tail] = memchi[i].dest;
      tail++;
    }
  } while (head < tail);
  for (register int i = 1; i <= n; i++) {
    if (!(!bv[i] || bv[i + n])) printf("%d ", i);
  }
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return (0);
}