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 = 200006;
const int INF = (int)1e9;
int e_num = 1, S, T;
int hed[maxn], dep[maxn];
struct Edge {
  int from, to, nxt, c;
} edge[maxn * 4];
void addedge(int from, int to, int c) {
  edge[++e_num] = (Edge){from, to, hed[from], c};
  hed[from] = e_num;
}
void adde(int from, int to, int c) {
  addedge(from, to, c);
  addedge(to, from, 0);
}
int que[maxn + 5], head = 0, tail = 0;
bool bfs() {
  head = tail = 0;
  que[tail++] = S;
  for (int i = 0; i <= T; i++) dep[i] = 0;
  dep[S] = 1;
  while (head != tail) {
    int cur = que[head++];
    head %= maxn;
    for (int i = hed[cur]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (!dep[to] && edge[i].c) {
        dep[to] = dep[cur] + 1;
        que[tail++] = to;
        tail %= maxn;
      }
    }
  }
  return dep[T];
}
int hed2[maxn];
int dfs(int x, int flow) {
  if (x == T) return flow;
  int ret = 0;
  for (int &i = hed2[x]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dep[to] == dep[x] + 1 && edge[i].c) {
      int tmp = dfs(to, min(flow, edge[i].c));
      edge[i].c -= tmp;
      edge[i ^ 1].c += tmp;
      flow -= tmp;
      ret += tmp;
      if (!flow) {
        break;
      }
    }
  }
  if (!ret) dep[x] = 0;
  return ret;
}
int dinic() {
  int ret = 0;
  while (bfs()) {
    memcpy(hed2, hed, sizeof hed);
    ret += dfs(S, INF);
  }
  return ret;
}
const int N = 760, M = 10000233;
int n, cnt = 1, ch[M][2], ed[M], fail[M];
vector<int> pos[N];
char s[M];
bitset<N> f[N];
int main() {
  scanf("%d", &n);
  for (int x = 1; x <= n; x++) {
    scanf("%s", s + 1);
    int L = (int)strlen(s + 1);
    int cur = 1;
    for (int i = 1; i <= L; i++) {
      if (!ch[cur][s[i] - 'a']) {
        ch[cur][s[i] - 'a'] = ++cnt;
      }
      cur = ch[cur][s[i] - 'a'];
      pos[x].push_back(cur);
    }
    ed[cur] = x;
  }
  queue<int> q;
  ch[0][0] = ch[0][1] = 1;
  q.push(1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (!ed[x]) {
      ed[x] = ed[fail[x]];
    }
    for (int i = 0; i < 2; i++) {
      if (!ch[x][i]) {
        ch[x][i] = ch[fail[x]][i];
      } else {
        fail[ch[x][i]] = ch[fail[x]][i];
        q.push(ch[x][i]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    f[i][i] = 1;
    for (auto x : pos[i]) {
      if (ed[x]) {
        f[i][ed[x]] = 1;
      }
    }
    if (ed[fail[pos[i].back()]]) {
      f[i][ed[fail[pos[i].back()]]] = 1;
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++)
      if (f[i][k]) {
        f[i] |= f[k];
      }
  }
  S = n * 2 + 1, T = n * 2 + 2;
  for (int i = 1; i <= n; i++) {
    adde(S, i, 1);
    adde(i + n, T, 1);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (i != j) {
        if (f[i][j]) {
          adde(i, j + n, 1);
        }
      }
  }
  printf("%d\n", n - dinic());
  for (int i = 1; i <= n; i++) {
    if (dep[i] && !dep[i + n]) {
      printf("%d ", i);
    }
  }
}