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("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 755, N = 10000010, SGM = 2;
int n, m, k, u, v, x, y, t, a, b, ans;
int C[N][SGM], F[N], ts;
int pos[MAXN], up[N];
int match[MAXN * 2], dist[MAXN * 2];
bool VC[MAXN], mark[MAXN], out[MAXN];
bool edge[MAXN][MAXN];
vector<int> G[MAXN];
string S[MAXN];
queue<int> Q;
int AddTrie(string &s) {
  int v = 0;
  for (char ch : s) {
    if (!C[v][ch - 'a']) C[v][ch - 'a'] = ++ts;
    v = C[v][ch - 'a'];
  }
  return v;
}
void BuildAho() {
  for (int i = 0; i < SGM; i++)
    if (C[0][i]) Q.push(C[0][i]);
  while (Q.size()) {
    int v = Q.front();
    Q.pop();
    if (!up[v]) up[v] = up[F[v]];
    for (int i = 0; i < SGM; i++) {
      if (!C[v][i])
        C[v][i] = C[F[v]][i];
      else {
        F[C[v][i]] = C[F[v]][i];
        Q.push(C[v][i]);
      }
    }
  }
}
bool bfs() {
  memset(dist, 31, sizeof(dist));
  for (int i = 1; i <= n; i++)
    if (!match[i]) {
      dist[i] = 0;
      Q.push(i);
    }
  bool res = 0;
  while (Q.size()) {
    int v = Q.front();
    Q.pop();
    if (v <= n) {
      VC[v] = 1;
      for (int u : G[v])
        if (dist[v] + 1 < dist[u]) {
          dist[u] = dist[v] + 1;
          Q.push(u);
        }
      continue;
    }
    if (!match[v]) {
      res = 1;
      continue;
    }
    dist[match[v]] = dist[v] + 1;
    Q.push(match[v]);
  }
  return res;
}
bool dfs(int node) {
  mark[node] = 1;
  for (int v : G[node])
    if (!match[v] ||
        dist[node] + 1 == dist[v] && !mark[match[v]] && dfs(match[v])) {
      match[node] = v;
      match[v] = node;
      return 1;
    }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> S[i], up[pos[i] = AddTrie(S[i])] = i;
  BuildAho();
  for (int i = 1; i <= n; i++) {
    int v = 0;
    for (char ch : S[i]) {
      v = C[v][ch - 'a'];
      for (int u = up[v]; u && !edge[u][i]; u = up[F[pos[u]]])
        if (i != u) {
          G[u].push_back(i + n);
          edge[u][i] = 1;
        }
    }
  }
  while (bfs()) {
    memset(VC, 0, sizeof(VC));
    memset(mark, 0, sizeof(mark));
    for (int i = 1; i <= n; i++)
      if (!match[i] && !mark[i]) ans += dfs(i);
  }
  for (int i = 1; i <= n; i++)
    if (match[i]) {
      if (VC[i])
        out[match[i] - n] = 1;
      else
        out[i] = 1;
    }
  cout << n - ans << '\n';
  for (int i = 1; i <= n; i++)
    if (!out[i]) cout << i << ' ';
  return 0;
}