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 std::bitset;
using std::cout;
using std::endl;
using std::make_pair;
using std::max;
using std::min;
using std::pair;
using std::swap;
using std::unordered_map;
using std::vector;
int read() {
  int f = 1;
  int h = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') h = (h << 1) + (h << 3) + c - '0', c = getchar();
  return h * f;
}
int n;
char S[10001000];
int lc;
bitset<777> Mp[777];
vector<int> s[777];
int lth[777];
struct ACAM {
  int fail[10000010];
  int ch[10000010][2];
  int ed[10000010];
  int cnt;
  void insert(int id) {
    int rt = 0;
    for (int i = 1; i <= lc; i++) {
      if (!ch[rt][S[i] - 'a']) ch[rt][S[i] - 'a'] = ++cnt;
      rt = ch[rt][S[i] - 'a'];
    }
    ed[rt] = id;
  }
  int que[10001000];
  int head, tail;
  void build_fail() {
    head = 0, tail = -1;
    que[++tail] = 0;
    while (head <= tail) {
      int rt = que[head++];
      if (!ed[rt]) ed[rt] = ed[fail[rt]];
      for (int i = 0; i <= 1; i++) {
        if (ch[rt][i]) {
          if (rt) fail[ch[rt][i]] = ch[fail[rt]][i];
          que[++tail] = ch[rt][i];
        } else
          ch[rt][i] = ch[fail[rt]][i];
      }
    }
  }
  void work() {
    for (int x = 1; x <= n; x++) {
      int rt = 0;
      for (int i = 1; i <= lth[x]; i++) {
        rt = ch[rt][s[x][i]];
        if (ed[rt]) Mp[x][ed[rt]] = 1;
      }
      if (ed[fail[rt]]) Mp[x][ed[fail[rt]]] = 1;
    }
  }
} t;
struct Edge {
  int to;
  int nxt;
  int f;
} edge[510050];
int frm[1555];
int cnt_e = -1;
int SS, TT;
void insert_e(int u, int v, int f) {
  cnt_e++;
  edge[cnt_e].to = v;
  edge[cnt_e].nxt = frm[u];
  edge[cnt_e].f = f;
  frm[u] = cnt_e;
}
void Insert(int u, int v, int f) {
  insert_e(u, v, f);
  insert_e(v, u, 0);
}
const int MAXN = 1555;
int cur[MAXN];
int dep[MAXN];
int que[MAXN], head, tail;
bool BFS() {
  head = 0, tail = -1;
  memcpy(cur, frm, sizeof(cur));
  memset(dep, -1, sizeof(dep));
  dep[SS] = 0;
  que[++tail] = SS;
  while (head <= tail) {
    int u = que[head++];
    for (int i = frm[u]; i != -1; i = edge[i].nxt) {
      int v = edge[i].to;
      if (edge[i].f && dep[v] == -1) {
        dep[v] = dep[u] + 1;
        que[++tail] = v;
      }
    }
  }
  return dep[TT] != -1;
}
int DFS(int x, int mneg) {
  if (x == TT || !mneg) return mneg;
  int floww = 0;
  for (int i = cur[x]; i != -1; i = edge[i].nxt) {
    cur[x] = i;
    int v = edge[i].to;
    if (dep[v] == dep[x] + 1 && edge[i].f) {
      int h = DFS(v, min(mneg, edge[i].f));
      edge[i].f -= h, edge[i ^ 1].f += h;
      floww += h, mneg -= h;
      if (!mneg) break;
    }
  }
  return floww;
}
int Dinic() {
  int anss = 0;
  while (BFS()) {
    anss += DFS(0, 100000000);
  }
  return anss;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%s", S + 1);
    lth[i] = lc = strlen(S + 1);
    s[i].push_back(-1);
    for (int j = 1; j <= lth[i]; j++) s[i].push_back(S[j] - 'a');
    t.insert(i);
  }
  t.build_fail();
  t.work();
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++)
      if (Mp[i][k]) Mp[i] |= Mp[k];
  }
  memset(frm, -1, sizeof(frm));
  SS = 0, TT = 2 * n + 1;
  for (int i = 1; i <= n; i++) Insert(SS, i, 1), Insert(i + n, TT, 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (i != j) {
        if (Mp[i][j]) Insert(i, j + n, 100000000);
      }
  }
  printf("%d\n", n - Dinic());
  for (int i = 1; i <= n; i++) {
    if (dep[i] != -1 && dep[i + n] == -1) {
      printf("%d ", i);
    }
  }
  puts("");
}