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;
template <class T>
inline void read(T &x) {
  int f = 0;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
namespace G {
const int N = 100005, inf = 1e9;
struct edge {
  int v, f, c, p;
};
vector<edge> e[N];
int d[N], r[N], in[N], n, m, s, t;
void init(int _n, int _s, int _t) { n = _n, s = _s, t = _t, m = 0; }
void add(int a, int b, int c) {
  e[a].push_back((edge){b, 0, c, (int)e[b].size()});
  e[b].push_back((edge){a, 0, 0, (int)e[a].size() - 1});
}
int bfs() {
  static int q[N];
  int l = 0, r = 0;
  fill(d + 1, d + n + 1, 0), d[s] = 1;
  for (l = r = 0, q[r++] = s; l < r;) {
    int u = q[l++];
    for (int i = (0); i < (e[u].size()); i++) {
      edge &v = e[u][i];
      if (!d[v.v] && v.f < v.c) {
        d[q[r++] = v.v] = d[u] + 1;
        if (v.v == t) return 1;
      }
    }
  }
  return 0;
}
int dfs(int u, int a) {
  if (u == t) return a;
  int res = 0;
  in[u] = 1;
  for (int &k = r[u]; k < e[u].size(); k++) {
    edge &v = e[u][k];
    if (v.f < v.c && d[v.v] == d[u] + 1 && !in[v.v]) {
      int now = dfs(v.v, min(a, v.c - v.f));
      v.f += now, e[v.v][v.p].f -= now, res += now;
      if (!(a -= now)) break;
    }
  }
  return in[u] = 0, res;
}
int flow() {
  int res = 0;
  while (bfs()) {
    fill(r + 1, r + n + 1, 0);
    res += dfs(s, inf);
  }
  return res;
}
}  // namespace G
const int N = 1505, M = 10001005;
int f[N][N], t[M][2], fail[M], g[M], p[N], vis[N], cur[N];
int n, sz = 1, rt = 1;
char s[M];
vector<int> e[N];
void ins(char s[], int id) {
  int o = rt;
  for (int i = 0; s[i]; i++) {
    if (!t[o][s[i] - 'a']) t[o][s[i] - 'a'] = ++sz;
    o = t[o][s[i] - 'a'];
  }
  g[o] = id;
}
void build() {
  static int q[M];
  int l = 0, r = 0, u;
  for (int c = (0); c < (2); c++)
    if (!t[rt][c])
      t[rt][c] = rt;
    else
      fail[q[r++] = t[rt][c]] = rt;
  while (l < r) {
    u = q[l++];
    if (!g[u]) g[u] = g[fail[u]];
    for (int c = (0); c < (2); c++)
      if (!t[u][c])
        t[u][c] = t[fail[u]][c];
      else
        fail[q[r++] = t[u][c]] = t[fail[u]][c];
  }
}
void walk(char s[], int id) {
  int o = rt;
  for (int i = 0; s[i]; i++) o = t[o][s[i] - 'a'], f[id][g[o]] = 1;
  f[id][g[fail[o]]] = 1;
}
void dfs(int u) {
  vis[u] = 1;
  for (auto v : e[u])
    if (cur[v] && !vis[v]) vis[v] = 1, dfs(cur[v]);
}
int main() {
  read(n);
  for (int i = (1); i <= (n); i++) {
    scanf("%s", s + p[i]);
    ins(s + p[i], i);
    p[i + 1] = p[i] + strlen(s + p[i]) + 1;
  }
  build();
  for (int i = (1); i <= (n); i++) walk(s + p[i], i);
  for (int k = (1); k <= (n); k++)
    for (int i = (1); i <= (n); i++)
      for (int j = (1); j <= (n); j++) f[i][j] |= f[i][k] & f[k][j];
  int S = n + n + 1, T = S + 1;
  G::init(T, S, T);
  for (int i = (1); i <= (n); i++) G::add(S, i, 1), G::add(i + n, T, 1);
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++)
      if (f[i][j] && i != j) {
        G::add(i, n + j, 1);
        e[n + j].push_back(i);
        e[i].push_back(n + j);
      }
  printf("%d\n", n - G::flow());
  for (int i = (1); i <= (n); i++)
    for (auto x : G::e[i])
      if (x.v != S && x.f) cur[i] = x.v, cur[x.v] = i;
  for (int i = (1); i <= (n); i++)
    if (!cur[i]) dfs(i);
  for (int i = (1); i <= (n); i++)
    if (vis[i] && !vis[i + n]) printf("%d ", i);
  puts("");
  return 0;
}