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>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using db = long double;
const int N = 750 + 5, M = 1e7 + 5, K = 2, MOD = 1e9 + 7, MOD2 = 998244353;
const ll MX = 1e15;
const int blkSz = 320;
int trie[M][K], ptr;
string str[N];
int mat[N][N], vis[N], match[N], cas, n;
int en[M];
int f[M];
int go[M][2];
int canMatch(int u) {
  for (int i = 1; i <= n; i++) {
    if (vis[i] != cas && mat[u][i]) {
      vis[i] = cas;
      if (!match[i] || canMatch(match[i])) {
        match[i] = u;
        return 1;
      }
    }
  }
  return 0;
}
void BFS() {
  queue<int> q;
  for (int i = 0; i < K; i++)
    if (trie[0][i]) q.push(trie[0][i]), f[trie[0][i]] = 0;
  for (int i = 0; i < K; i++) go[0][i] = trie[0][i];
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < K; i++) {
      if (trie[x][i]) {
        int y = trie[x][i];
        f[y] = f[x];
        while (f[y] && !trie[f[y]][i]) f[y] = f[f[y]];
        if (trie[f[y]][i]) f[y] = trie[f[y]][i];
        if (!en[y]) en[y] = en[f[y]];
        q.push(y);
      }
      if (trie[x][i])
        go[x][i] = trie[x][i];
      else
        go[x][i] = go[f[x]][i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
    int cur = 0;
    for (int j = 0; j < str[i].size(); j++) {
      if (!trie[cur][str[i][j] - 'a']) trie[cur][str[i][j] - 'a'] = ++ptr;
      cur = trie[cur][str[i][j] - 'a'];
    }
    en[cur] = i;
  }
  BFS();
  for (int i = 1; i <= n; i++) {
    int cur = 0;
    for (int j = 0; j < str[i].size(); j++) {
      cur = trie[cur][str[i][j] - 'a'];
      if (en[cur] && en[cur] != i) mat[en[cur]][i] = 1;
    }
    if (en[f[cur]]) mat[en[f[cur]]][i] = 1;
  }
  for (int i = 1; i <= n; i++) mat[i][i] = 1;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) mat[i][j] |= mat[i][k] & mat[k][j];
  for (int i = 1; i <= n; i++) mat[i][i] = 0;
  int ans = n;
  for (int i = 1; i <= n; i++) {
    ++cas;
    ans -= canMatch(i);
  }
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++) vis[match[i]] = 1;
  vector<int> out;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) out.push_back(i);
  bool f = true;
  cout << ans << endl;
  while (f) {
    f = false;
    for (auto& x : out) {
      for (auto& y : out) {
        if (mat[x][y]) {
          y = match[y];
          f = true;
        }
        if (f) break;
      }
      if (f) break;
    }
  }
  for (auto x : out) cout << x << " ";
  return 0;
}