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 inft = 1000000009;
const int MAXN = 753;
const int MAXSUM = 10000007;
string S[MAXN];
char input[MAXSUM];
int H[MAXN];
int per[MAXN];
bool bad[MAXN];
bool cmp(const int &a, const int &b) {
  if (S[a].size() != S[b].size()) return S[a].size() < S[b].size();
  return a < b;
}
struct node {
  node *M[2];
  int koniec;
  node *hop;
  node *suf;
  node() {
    for (int i = 0; i < (2); ++i) M[i] = NULL;
    koniec = -1;
    hop = suf = NULL;
  }
  bool add(unsigned int q, string &SS, int nr) {
    if (q == SS.size()) {
      if (koniec != -1) return 0;
      koniec = nr;
      return 1;
    } else {
      if (M[SS[q]] == NULL) M[SS[q]] = new node();
      return M[SS[q]]->add(q + 1, SS, nr);
    }
  }
};
node *Q[MAXSUM];
int qs;
void aho_corasic(node *POCZ) {
  qs = 0;
  Q[qs++] = POCZ;
  for (int i = 0; i < (qs); ++i) {
    node *T = Q[i];
    for (int j = 0; j < (2); ++j)
      if (T->M[j]) {
        node *C = T->suf;
        while (C != POCZ && C->M[j] == NULL) C = C->suf;
        if (i && C->M[j]) C = C->M[j];
        T->M[j]->suf = C;
        if (C->koniec != -1)
          T->M[j]->hop = C;
        else
          T->M[j]->hop = C->hop;
        Q[qs++] = T->M[j];
      }
  }
}
bitset<MAXN> SAS[MAXN];
namespace TM {
const int MAXN = 1505;
vector<int> V[MAXN];
int c, d;
int M[MAXN];
bool odw[MAXN];
queue<int> Q;
inline bool dfs(int u) {
  odw[u] = 1;
  Q.push(u);
  for (typeof((V[u]).begin()) it = (V[u]).begin(); it != (V[u]).end(); ++it)
    if ((M[*it] == -1) || (!odw[M[*it]] && dfs(M[*it]))) {
      M[u] = *it;
      M[*it] = u;
      return 1;
    }
  return 0;
}
vector<int> IS, VC;
bool TT[MAXN];
void d2(int u) {
  if (TT[u]) return;
  TT[u] = 1;
  for (typeof((V[u]).begin()) it = (V[u]).begin(); it != (V[u]).end(); ++it)
    TT[*it] = 1, d2(M[*it]);
}
int matching() {
  for (int i = 0; i < (c); ++i) odw[i] = 0;
  for (int i = 0; i < (c + d); ++i) M[i] = -1;
  bool czy = 1;
  while (czy) {
    for (czy = 0; !Q.empty(); Q.pop()) odw[Q.front()] = 0;
    for (int i = 0; i < (c); ++i)
      if (M[i] == -1 && !odw[i]) czy |= dfs(i);
  }
  int ret = 0;
  for (int i = 0; i < (c); ++i)
    if (M[i] != -1) ++ret;
  if (1) {
    for (int i = 0; i < (c + d); ++i) TT[i] = 0;
    for (int i = 0; i < (c); ++i)
      if (M[i] == -1) d2(i);
    for (int i = 0; i < (c); ++i)
      if (TT[i] == 1) IS.push_back(i);
    for (int i = 0; i < (d); ++i)
      if (TT[i + c] == 0) IS.push_back(i + c);
  }
  return ret;
}
}  // namespace TM
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%s", input);
    S[i] = string(input);
    for (typeof((S[i]).begin()) it = (S[i]).begin(); it != (S[i]).end(); ++it)
      *it -= 'a';
    H[i] = 123;
    for (typeof((S[i]).begin()) it = (S[i]).begin(); it != (S[i]).end(); ++it)
      H[i] = (H[i] * 41311LL + *it) % 1000000123;
  }
  for (int i = 0; i < (n); ++i) SAS[i][i] = 1;
  for (int i = 0; i < (n); ++i) per[i] = i;
  sort(per, per + n, cmp);
  node *D = new node();
  D->suf = D->hop = D;
  for (int i = 0; i < (n); ++i)
    if (D->add(0, S[per[i]], per[i]) == 0) bad[per[i]] = 1;
  aho_corasic(D);
  for (int i = 0; i < (n); ++i)
    if (!bad[i]) {
      int u = per[i];
      node *E = D;
      for (typeof((S[u]).begin()) it = (S[u]).begin(); it != (S[u]).end();
           ++it) {
        while (E != D && E->M[*it] == NULL) E = E->suf;
        if (E->M[*it]) E = E->M[*it];
        if (E->hop->koniec != -1) SAS[u][E->hop->koniec] = 1;
        if (E->koniec != -1) SAS[u][E->koniec] = 1;
      }
      for (int j = 0; j < (n); ++j)
        if (SAS[u][j]) SAS[u] |= SAS[j];
    }
  vector<int> OK;
  for (int i = 0; i < (n); ++i)
    if (!bad[i]) OK.push_back(i);
  int m = OK.size();
  TM::c = TM::d = m;
  for (int i = 0; i < (m); ++i)
    for (int j = 0; j < (m); ++j)
      if (i != j && SAS[OK[i]][OK[j]]) {
        TM::V[i].push_back(j + m);
      }
  TM::matching();
  vector<int> ANS;
  for (int i = 0; i < (m); ++i)
    if (binary_search((TM::IS).begin(), (TM::IS).end(), i) &&
        binary_search((TM::IS).begin(), (TM::IS).end(), i + n))
      ANS.push_back(OK[i]);
  printf("%lu\n", ANS.size());
  for (typeof((ANS).begin()) it = (ANS).begin(); it != (ANS).end(); ++it)
    printf("%d ", *it + 1);
  printf("\n");
  return 0;
}