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 = 753, MXN = 10000007, SGM = 2;
int n, MC[N * 2];
bool M[N * 2], VC[N * 2], E[N][N];
vector<int> Adj[N * 2];
int ts, C[MXN][SGM], Suf[MXN], Qu[MXN], AC[MXN];
string S[N];
inline void Add(string &ss, int j) {
  int id = 0;
  for (int i = 0; i < (int)ss.size(); i++) {
    if (!C[id][ss[i] - 'a']) C[id][ss[i] - 'a'] = ++ts;
    id = C[id][ss[i] - 'a'];
  }
  AC[id] = j;
}
inline void AhoCorasick() {
  int l = 0, r = 0;
  for (int i = 0; i < SGM; i++)
    if (C[0][i]) Qu[r++] = C[0][i];
  while (r - l) {
    int id = Qu[l++];
    for (int i = 0; i < SGM; i++) {
      if (!C[id][i])
        C[id][i] = C[Suf[id]][i];
      else
        Qu[r++] = C[id][i], Suf[C[id][i]] = C[Suf[id]][i];
    }
    if (!AC[id]) AC[id] = AC[Suf[id]];
  }
}
bool DFS(int v) {
  if (M[v]) return 0;
  M[v] = 1;
  for (int u : Adj[v])
    if (MC[u] == -1 || DFS(MC[u])) return (MC[u] = v, MC[v] = u), 1;
  return 0;
}
void DFS2(int v) {
  VC[v] = 1;
  for (int u : Adj[MC[v]])
    if (MC[u] != -1 && !VC[u]) DFS2(u);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> S[i], Add(S[i], i);
  AhoCorasick();
  for (int i = 1; i <= n; i++) {
    int id = 0;
    for (int j = 0; j < (int)S[i].size(); j++) {
      id = C[id][S[i][j] - 'a'];
      if (AC[id] && AC[id] != i)
        E[i][AC[id]] = 1;
      else if (AC[id] == i && AC[Suf[id]])
        E[i][AC[Suf[id]]] = 1;
    }
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) E[i][j] |= (E[i][k] & E[k][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j && E[i][j]) Adj[i + n].push_back(j), Adj[j].push_back(i + n);
  memset(MC, -1, sizeof(MC));
  while (N) {
    bool NotDone = 0;
    memset(M, 0, sizeof(M));
    for (int i = 1; i <= n + n; i++)
      if (MC[i] == -1 && !M[i]) NotDone |= DFS(i);
    if (!NotDone) break;
  }
  for (int i = 1; i <= n + n; i++)
    if (MC[i] == -1)
      for (int u : Adj[i])
        if (MC[u] != -1) DFS2(u);
  for (int i = 1; i <= n + n; i++)
    if (MC[i] != -1 && !VC[i] && !VC[MC[i]]) VC[i] = 1;
  vector<int> vec;
  for (int i = 1; i <= n; i++)
    if (!VC[i] && !VC[i + n]) vec.push_back(i);
  printf("%d\n", (int)vec.size());
  for (int v : vec) printf("%d ", v);
  return 0;
}