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 + 3;
queue<int> q;
char s[maxn];
int ch[maxn][2], f[maxn], tag[maxn], tott;
int head[2002], tot = 1, deep[2002], cur[2002], l[2002], r[2002], ans, n;
int su[maxn];
bool a[752][752];
inline long long rd() {
  long long x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}
struct edge {
  int n, to, l;
} e[2002 * 2002];
inline void add(int u, int v, int l) {
  e[++tot].n = head[u];
  e[tot].to = v;
  head[u] = tot;
  e[tot].l = l;
  e[++tot].n = head[v];
  e[tot].to = u;
  head[v] = tot;
  e[tot].l = 0;
}
inline bool bfs(int s, int t) {
  memset(deep, 0, sizeof(deep));
  memcpy(cur, head, sizeof(cur));
  q.push(s);
  deep[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].n) {
      int v = e[i].to;
      if (!deep[v] && e[i].l) {
        deep[v] = deep[u] + 1;
        q.push(v);
      }
    }
  }
  return deep[t];
}
int dfs(int u, int t, int l) {
  if (u == t || !l) return l;
  int f, flow = 0;
  for (int &i = cur[u]; i; i = e[i].n) {
    int v = e[i].to;
    if (deep[u] + 1 == deep[v] && (f = dfs(v, t, min(l, e[i].l)))) {
      flow += f;
      e[i].l -= f;
      e[i ^ 1].l += f;
      l -= f;
      if (!l) break;
    }
  }
  return flow;
}
inline void insert(int id, int n) {
  int now = 0;
  l[id] = r[id - 1] + 1;
  r[id] = r[id - 1];
  for (int i = 1; i <= n; ++i) {
    if (!ch[now][s[i] - 'a']) ch[now][s[i] - 'a'] = ++tott;
    now = ch[now][s[i] - 'a'];
    su[++r[id]] = now;
  }
  tag[now] = id;
}
inline void get_fail() {
  for (int i = 0; i < 2; ++i)
    if (ch[0][i]) q.push(ch[0][i]);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 2; ++i) {
      if (ch[u][i]) {
        f[ch[u][i]] = ch[f[u]][i];
        q.push(ch[u][i]);
        if (!tag[ch[u][i]] && tag[f[ch[u][i]]]) {
          tag[ch[u][i]] = tag[f[ch[u][i]]];
        }
      } else
        ch[u][i] = ch[f[u]][i];
    }
  }
}
inline void work(int id) {
  for (int i = l[id]; i <= r[id]; ++i) {
    int x = su[i];
    if (tag[x]) a[id][tag[x]] = 1;
  }
  if (f[su[r[id]]]) a[id][tag[f[su[r[id]]]]] = 1;
}
int main() {
  n = rd();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    insert(i, strlen(s + 1));
  }
  get_fail();
  for (int i = 1; i <= n; ++i) {
    work(i);
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) a[i][j] |= a[i][k] & a[k][j];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j)
      if (i != j && a[i][j]) {
        add(i, j + n, 1);
      }
  }
  for (int i = 1; i <= n; ++i) {
    add(0, i, 1);
    add(i + n, 2 * n + 1, 1);
  }
  while (bfs(0, 2 * n + 1)) ans += dfs(0, 2 * n + 1, 1e9);
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; ++i) {
    if (deep[i] && !deep[i + n]) printf("%d ", i);
  }
  return 0;
}