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 = 1e3 + 3, M = 1e7 + 5;
int n, cnt, num = 1, fir[N << 1], len[N], ch[M][2], bo[M], nxt[M], las[M],
            b[N][N], S, T, d[N << 1], ans, tag[N << 1];
char s[M], *c[N];
struct hh {
  int to, nxt, c;
} e[N * N << 2];
inline void add(int x, int y, int c) {
  e[++num] = (hh){y, fir[x], c}, fir[x] = num, e[++num] = (hh){x, fir[y], 0},
  fir[y] = num;
}
inline void ins(char *c, int k) {
  int u = 0, v;
  for (int i = 1; i <= len[k]; ++i) {
    v = c[i] - 'a';
    if (!ch[u][v]) ch[u][v] = ++cnt;
    u = ch[u][v];
  }
  bo[u] = k;
}
void deal() {
  queue<int> q;
  for (int i = 0; i < 2; ++i)
    if (ch[0][i]) q.push(ch[0][i]);
  while (q.size()) {
    int u = q.front();
    q.pop();
    las[u] = bo[nxt[u]] ? nxt[u] : las[nxt[u]];
    for (int i = 0; i < 2; ++i)
      if (ch[u][i])
        nxt[ch[u][i]] = ch[nxt[u]][i], q.push(ch[u][i]);
      else
        ch[u][i] = ch[nxt[u]][i];
  }
}
void ask(char *c, int k) {
  int u = 0, v, now;
  for (int i = 1; i <= len[k]; ++i) {
    u = ch[u][c[i] - 'a'];
    if (bo[u] && bo[u] ^ k) b[bo[u]][k] = 1;
    if (bo[las[u]] && bo[las[u]] ^ k) b[bo[las[u]]][k] = 1;
  }
}
int bfs() {
  queue<int> q;
  memset(d, 0, sizeof(d));
  d[S] = 1, q.push(S);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = fir[u], v; v = e[i].to, i; i = e[i].nxt)
      if (e[i].c && !d[v]) {
        d[v] = d[u] + 1;
        q.push(v);
        if (v == T) return 1;
      }
  }
  return 0;
}
int dinic(int u, int flow) {
  if (u == T) return flow;
  int res = flow;
  for (int i = fir[u], v; v = e[i].to, i && res; i = e[i].nxt)
    if (d[v] == d[u] + 1 && e[i].c) {
      int k = dinic(v, min(res, e[i].c));
      if (!k) d[v] = 0;
      res -= k, e[i].c -= k, e[i ^ 1].c += k;
    }
  return flow - res;
}
void dfs(int u) {
  tag[u] = 1;
  for (int i = fir[u], v; v = e[i].to, i; i = e[i].nxt)
    if (!e[i].c && v ^ T && v ^ S && !tag[v]) dfs(v);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    len[i] = strlen(s + 1);
    c[i] = new char[len[i] + 5];
    memcpy(c[i] + 1, s + 1, len[i]);
  }
  for (int i = 1; i <= n; ++i) ins(c[i], i);
  deal();
  for (int i = 1; i <= n; ++i) ask(c[i], i);
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) b[i][j] = b[i][j] | (b[i][k] & b[k][j]);
  S = 0, T = 2 * n + 1;
  for (int i = 1; i <= n; ++i) add(S, i, 1), add(i + n, T, 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (b[i][j]) add(i, j + n, 1);
  while (bfs()) ans += dinic(S, 1e9);
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; ++i)
    for (int j = fir[i + n], v; v = e[j].to, j; j = e[j].nxt)
      if (v == T && e[j].c) dfs(i + n);
  for (int i = 1; i <= n; ++i)
    if (!tag[i] && tag[i + n]) printf("%d ", i);
  printf("\n");
  return 0;
}