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 = 1e7 + 10, sigma = 2;
int term[MAXN], to[MAXN][sigma], link[MAXN], sz = 1;
int que[MAXN], ww[MAXN];
namespace MF {
const int N = 755 * 2, M = 755 * 755;
int f[N], e[2 * M], c[2 * M], fl[2 * M], nxt[2 * M], ce;
int n, s, t;
int Q[N], lvl[N];
int le[N];
void init(int _n) {
  n = _n + 2;
  s = _n;
  t = _n + 1;
  ce = 0;
  for (int i = (0); i < (n); i++) f[i] = -1;
}
void add(int a, int b, int cap) {
  nxt[ce] = f[a];
  f[a] = ce;
  e[ce] = b;
  fl[ce] = 0;
  c[ce] = cap;
  ce++;
  nxt[ce] = f[b];
  f[b] = ce;
  e[ce] = a;
  fl[ce] = 0;
  c[ce] = 0;
  ce++;
}
bool bfs() {
  for (int i = (0); i < (n); i++) lvl[i] = -1;
  int qi = 1;
  Q[0] = s;
  lvl[s] = 0;
  for (int i = (0); i < (qi); i++) {
    int x = Q[i];
    le[x] = f[x];
    for (int j = f[x]; j >= 0; j = nxt[j])
      if (c[j] - fl[j] > 0) {
        int y = e[j];
        if (lvl[y] == -1) {
          lvl[y] = lvl[x] + 1;
          Q[qi++] = y;
        }
      }
  }
  return lvl[t] != -1;
}
int aug(int cu, int cf) {
  if (cu == t) return cf;
  for (int &i = le[cu]; i >= 0; i = nxt[i])
    if (c[i] - fl[i] > 0) {
      int x = e[i];
      if (lvl[x] != lvl[cu] + 1) continue;
      int rf = aug(x, min(cf, c[i] - fl[i]));
      if (rf > 0) {
        fl[i] += rf;
        fl[i ^ 1] -= rf;
        return rf;
      }
    }
  lvl[cu] = -1;
  return 0;
}
int mf() {
  int tot = 0;
  while (bfs())
    for (int x = aug(s, 1e9); x; x = aug(s, 1e9)) tot += x;
  return tot;
}
}  // namespace MF
void add_str(string &s, int i) {
  int cur = 0;
  for (auto c : s) {
    if (!to[cur][c - 'a']) {
      to[cur][c - 'a'] = sz++;
    }
    cur = to[cur][c - 'a'];
  }
  term[cur] = cur;
  ww[cur] = i;
}
int u[755][755];
int mt[755][755];
int ei[755][755];
bool inz[2][755];
void calc_str(string &s, int i) {
  int cur = 0;
  for (auto c : s) {
    cur = to[cur][c - 'a'];
    for (int sl = term[cur]; sl; sl = term[link[sl]]) {
      if (u[i][ww[sl]]) break;
      u[i][ww[sl]] = true;
    }
  }
}
void push_links() {
  int st = 0, fi = 1;
  que[0] = 0;
  while (st < fi) {
    int V = que[st++];
    int U = link[V];
    if (!term[V]) term[V] = term[U];
    for (int c = 0; c < sigma; c++)
      if (to[V][c]) {
        link[to[V][c]] = V ? to[U][c] : 0;
        que[fi++] = to[V][c];
      } else {
        to[V][c] = to[U][c];
      }
  }
}
int n;
vector<string> v;
void go(int s, int i) {
  if (inz[s][i]) return;
  inz[s][i] = true;
  for (int j = (0); j < (n); j++) {
    if (s == 0) {
      if (u[i][j] && !mt[i][j]) go(1, j);
    } else {
      if (u[j][i] && mt[j][i]) go(0, j);
    }
  }
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(false);
  cin >> n;
  v.resize(n);
  for (int i = (0); i < (n); i++) {
    cin >> v[i];
    add_str(v[i], i);
  }
  push_links();
  for (int i = (0); i < (n); i++) {
    calc_str(v[i], i);
  }
  for (int i = (0); i < (n); i++) {
    u[i][i] = false;
    for (int j = (0); j < (n); j++)
      if (u[i][j]) {
      }
  }
  MF::init(2 * n);
  for (int i = (0); i < (n); i++) {
    MF::add(MF::s, i, 1);
    MF::add(n + i, MF::t, 1);
  }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++)
      if (u[i][j]) {
        ei[i][j] = MF::ce;
        MF::add(i, j + n, 1);
      }
  int flo = MF::mf();
  printf("%d\n", n - flo);
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++)
      if (u[i][j] && MF::fl[ei[i][j]]) {
        mt[i][j] = 1;
      }
  for (int i = (0); i < (n); i++) {
    bool unm = true;
    for (int j = (0); j < (n); j++)
      if (mt[i][j]) {
        unm = false;
      }
    if (unm) go(0, i);
  }
  vector<int> res;
  for (int i = (0); i < (n); i++)
    if (inz[0][i] && !inz[1][i]) res.push_back(i);
  assert(n - flo == int(res.size()));
  for (int x : res) printf("%d ", x + 1);
  printf("\n");
}