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;
string words[MAXN];
int n, ct = 0;
struct Node {
  Node *c[2], *f, *out;
  bool vis;
  vector<int> num;
  Node() {
    c[0] = c[1] = f = out = 0;
    vis = 0;
  }
};
Node *root;
void makeTrie() {
  root = new Node();
  for (int j = 0; j < n; ++j) {
    Node *here = root;
    string g = words[j];
    for (int i = 0; i < g.length(); ++i) {
      if (here->c[g[i] - 'a'] == 0) here->c[g[i] - 'a'] = new Node();
      here = here->c[g[i] - 'a'];
    }
    here->num.push_back(j);
  }
  for (int i = 0; i < 2; ++i) {
    if (root->c[i] == 0) root->c[i] = root;
  }
}
void makeFail() {
  queue<Node *> q;
  root->out = root;
  root->vis = 1;
  for (int i = 0; i < 2; ++i) {
    if ((root->c[i] != 0) && (root->c[i] != root)) {
      root->c[i]->f = root;
      root->c[i]->out = root;
      q.push(root->c[i]);
    }
  }
  while (!q.empty()) {
    Node *v = q.front();
    q.pop();
    for (int i = 0; i < 2; ++i) {
      if (v->c[i] == 0) continue;
      Node *here = v->c[i];
      Node *prev = v->f;
      while (prev->c[i] == 0) {
        prev = prev->f;
      }
      here->f = prev->c[i];
      here->out = (here->f->num.size() > 0) ? (here->f) : here->f->out;
      q.push(here);
    }
  }
}
bool poset[MAXN][MAXN];
void makePoset() {
  for (int i = 0; i < n; ++i) {
    string g = words[i];
    vector<Node *> clean;
    Node *here = root;
    for (int j = 0; j < g.length(); ++j) {
      while (here->c[g[j] - 'a'] == 0) here = here->f;
      here = here->c[g[j] - 'a'];
      Node *here2 = here;
      while (here2->vis == 0) {
        for (int k : here2->num) {
          poset[i][k] = 1;
          here2->vis = 1;
          clean.push_back(here2);
        }
        here2 = here2->out;
      }
    }
    for (Node *k : clean) k->vis = 0;
  }
}
bool visited[MAXN];
int match[MAXN], matchr[MAXN];
vector<int> adj[MAXN];
bool dfs(int x) {
  visited[x] = 1;
  for (int i : adj[x]) {
    if (match[i] == -1 || (!visited[match[i]] && dfs(match[i]))) {
      match[i] = x;
      return 1;
    }
  }
  return 0;
}
int matching() {
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (poset[i][j]) {
        if (poset[j][i] && j >= i) continue;
        adj[j].push_back(i);
      }
    }
  for (int i = 0; i < n; ++i) match[i] = matchr[i] = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) visited[j] = 0;
    ans += dfs(i);
  }
  for (int i = 0; i < n; ++i)
    if (match[i] != -1) matchr[match[i]] = i;
  return ans;
}
vector<int> antichain;
bool elim[MAXN];
bool chk[MAXN];
bool inside[MAXN];
void makeAntichain() {
  queue<int> last;
  for (int i = 0; i < n; ++i) {
    if (matchr[i] == -1) {
      last.push(i);
      inside[i] = true;
    }
  }
  int ct = 0;
  while (true) {
    if (ct >= 2000) break;
    int t = last.front();
    last.pop();
    if (elim[t]) {
      ct = 0;
      continue;
    }
    if (chk[t]) {
      last.push(t);
      ct++;
      continue;
    }
    chk[t] = true;
    ct = 0;
    for (int x : adj[t]) {
      elim[x] = true;
      if (match[x] != -1 && !inside[match[x]]) {
        last.push(match[x]);
        inside[match[x]] = true;
      }
    }
    last.push(t);
  }
  while (!last.empty()) {
    antichain.push_back(last.front());
    last.pop();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> words[i];
  makeTrie();
  makeFail();
  makePoset();
  cout << n - matching() << endl;
  makeAntichain();
  for (int i = 0; i < antichain.size(); ++i) {
    cout << antichain[i] + 1 << ' ';
  }
  cout << endl;
}