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 = 755, M = 1e7 + 5;
int n, tot = 1, ed[N], de[M], fail[M], d[N][N], fa[M], ch[M][2], v[N], mat[N],
       s[N], t[N], hav[N];
int dfs(int x) {
  for (int i = 1; i <= n; ++i)
    if (d[x][i] && !v[i]) {
      v[i] = 1;
      if (!mat[i] || dfs(mat[i])) return mat[i] = x, 1;
    }
  return 0;
}
void dfs2(int x) {
  s[x] = 1;
  for (int i = 1; i <= n; ++i)
    if (d[x][i] && !t[i]) {
      t[i] = 1;
      dfs2(mat[i]);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    int p = 1;
    for (int j = 0; j < s.length(); ++j) {
      int c = s[j] - 'a';
      if (!ch[p][c]) fa[ch[p][c] = ++tot] = p;
      p = ch[p][c];
    }
    ed[i] = p, de[p] = i;
  }
  queue<int> q;
  for (int i = 0; i < 2; ++i)
    if (ch[1][i])
      q.push(ch[1][i]), fail[ch[1][i]] = 1;
    else
      ch[1][i] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < 2; ++i)
      if (ch[x][i])
        fail[ch[x][i]] = ch[fail[x]][i], q.push(ch[x][i]);
      else
        ch[x][i] = ch[fail[x]][i];
  }
  de[1] = -1;
  for (int i = 1; i <= n; ++i)
    for (int j = ed[i]; j != 1; j = fa[j]) {
      int x = fail[j];
      vector<int> t;
      while (!de[x]) t.push_back(x), x = fail[x];
      for (auto y : t) fail[y] = x;
      fail[j] = x;
      if (j != ed[i] && de[j]) x = j;
      if (x != 1) d[i][de[x]] = 1;
    }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) d[i][j] |= d[i][k] & d[k][j];
  for (int i = 1; i <= n; ++i) d[i][i] = 0;
  int ans = n;
  for (int i = 1; i <= n; ++i) {
    memset(v, 0, sizeof v);
    ans -= dfs(i);
  }
  for (int i = 1; i <= n; ++i) hav[mat[i]] = 1;
  for (int i = 1; i <= n; ++i)
    if (!hav[i]) dfs2(i);
  cout << ans << endl;
  for (int i = 1; i <= n; ++i)
    if (s[i] && !t[i]) cout << i << ' ';
  return 0;
}