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 = 755;
int n, tr[maxn][maxn];
namespace ACAM {
const int maxp = 10000005;
char s[maxp];
int ed[maxn];
int rt = 1, totp = 1;
int ch[maxp][2], fail[maxp], fa[maxp], pos[maxp];
void insert(char *s, int x) {
  int len = strlen(s + 1);
  int nw = rt;
  for (int i = 1; i <= len; i++) {
    int c = s[i] - 'a';
    if (!ch[nw][c]) {
      ch[nw][c] = ++totp;
      fa[ch[nw][c]] = nw;
    }
    nw = ch[nw][c];
  }
  ed[x] = nw, pos[nw] = x;
}
void getfail() {
  queue<int> Q;
  for (int i = 0; i < 2; i++) {
    if (ch[rt][i])
      fail[ch[rt][i]] = rt, Q.push(ch[rt][i]);
    else
      ch[rt][i] = rt;
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (!pos[u]) pos[u] = pos[fail[u]];
    for (int i = 0; i < 2; i++) {
      if (ch[u][i])
        fail[ch[u][i]] = ch[fail[u]][i], Q.push(ch[u][i]);
      else
        ch[u][i] = ch[fail[u]][i];
    }
  }
}
void init() {
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    insert(s, i);
  }
  getfail();
  for (int i = 1; i <= n; i++) {
    if (pos[fail[ed[i]]]) tr[i][pos[fail[ed[i]]]] = 1;
    for (int j = fa[ed[i]]; j != rt; j = fa[j])
      if (pos[j]) tr[i][pos[j]] = 1;
  }
}
}  // namespace ACAM
namespace solver {
const int maxp = maxn << 1;
const int maxm = maxn * maxn;
const int inf = 0x3f3f3f3f;
int last[maxp], Next[maxm << 1], to[maxm << 1], w[maxm << 1], cnt = 1;
inline void addedge(int x, int y, int z) {
  Next[++cnt] = last[x], last[x] = cnt;
  to[cnt] = y, w[cnt] = z;
}
inline void add(int x, int y, int z) { addedge(x, y, z), addedge(y, x, 0); }
int st, ed, dep[maxp];
queue<int> Q;
bool bfs() {
  memset(dep, 0, sizeof(dep));
  dep[st] = 1;
  Q.push(st);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = last[u]; i; i = Next[i]) {
      int v = to[i];
      if (w[i] && !dep[v]) {
        dep[v] = dep[u] + 1;
        Q.push(v);
      }
    }
  }
  return dep[ed];
}
int cur[maxp];
int dfs(int x, int low) {
  if (x == ed) return low;
  int add = 0;
  for (int i = cur[x]; i && add < low; i = Next[i]) {
    cur[x] = i;
    int v = to[i];
    if (w[i] && dep[v] == dep[x] + 1) {
      int tmp = dfs(v, min(low - add, w[i]));
      w[i] -= tmp, w[i ^ 1] += tmp;
      add += tmp;
    }
  }
  return add;
}
int dinic() {
  int res = 0;
  while (bfs()) {
    memcpy(cur, last, sizeof(last));
    res += dfs(st, inf);
  }
  return res;
}
int El[maxn], Er[maxn], match[maxn];
int visl[maxn], visr[maxn];
void mark(int x) {
  visr[x] = 1;
  for (int i = 1; i <= n; i++)
    if (tr[i][x] && !visl[i]) visl[i] = 1, mark(match[i]);
}
void solve() {
  ed = n * 2 + 1;
  for (int i = 1; i <= n; i++) {
    add(st, i, 1), El[i] = cnt - 1;
    add(i + n, ed, 1), Er[i] = cnt - 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (tr[i][j]) add(i, j + n, 1);
  printf("%d\n", n - dinic());
  for (int i = 1; i <= n; i++)
    if (!w[El[i]]) {
      for (int j = last[i]; j; j = Next[j])
        if (!w[j] && to[j] != st) match[i] = to[j] - n;
    }
  for (int i = 1; i <= n; i++)
    if (w[Er[i]]) mark(i);
  for (int i = 1; i <= n; i++)
    if (!visl[i] && visr[i]) printf("%d ", i);
  puts("");
}
}  // namespace solver
int main() {
  scanf("%d", &n);
  ACAM ::init();
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) tr[i][j] |= (tr[i][k] & tr[k][j]);
  solver ::solve();
  return 0;
}