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 = 750 + 5, M = 1e7 + 5;
int nxt[M][2], id[M], q[M], f[M];
bitset<N> ed[N], mark, chain;
int n, m, L, R, match[N][2];
vector<int> adj[N];
string s[N];
bool match_dfs(int u) {
  if (mark[u]) return false;
  mark.set(u);
  for (auto v : adj[u])
    if (!~match[v][1] || match_dfs(match[v][1])) {
      match[match[u][0] = v][1] = u;
      return true;
    }
  return false;
}
void mark_dfs(int u) {
  mark.set(u);
  for (auto v : adj[u])
    if (!mark[match[v][1]]) mark_dfs(match[v][1]);
}
inline void add_trie(int p) {
  int cur = 0;
  for (auto c : s[p]) {
    if (!nxt[cur][c - 'a']) nxt[cur][c - 'a'] = ++m;
    cur = nxt[cur][c - 'a'];
  }
  id[cur] = p + 1;
}
inline void go(int p) {
  int cur = 0;
  for (auto c : s[p]) {
    if (id[cur = nxt[cur][c - 'a']]) ed[p][id[cur] - 1] = true;
    if (id[f[cur]]) ed[p][id[f[cur]] - 1] = true;
  }
}
inline void make_aho() {
  for (int i = 0; i < 2; i++)
    if (nxt[0][i]) q[R++] = nxt[0][i];
  for (int u = q[L]; L < R; u = q[++L]) {
    if (!id[u]) id[u] = id[f[u]];
    for (int i = 0; i < 2; i++)
      if (nxt[u][i])
        f[q[R++] = nxt[u][i]] = nxt[f[u]][i];
      else
        nxt[u][i] = nxt[f[u]][i];
  }
}
inline void make_graph() {
  for (int i = 0; i < n; i++) go(i);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (ed[j][i]) ed[j] |= ed[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i ^ j && ed[i][j]) adj[j].push_back(i);
}
inline void find_matching() {
  memset(match, -1, sizeof match);
  while (true) {
    bool flag = false;
    for (int i = 0; i < n; i++)
      if (!~match[i][0] && match_dfs(i)) flag = true;
    mark.reset();
    if (!flag) break;
  }
}
inline void find_antichain() {
  for (int i = 0; i < n; i++)
    if (!~match[i][0] && !mark[i]) mark_dfs(i);
  for (int i = 0; i < n; i++)
    chain[i] = mark[i] && (!~match[i][1] || !mark[match[i][1]]);
}
inline void read_input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    add_trie(i);
  }
}
inline void solve() {
  make_aho();
  make_graph();
  find_matching();
  find_antichain();
}
inline void write_output() {
  cout << chain.count() << endl;
  for (int i = 0; i < n; i++)
    if (chain[i]) cout << i + 1 << ' ';
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}