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 INF = 0x3f3f3f3f;
namespace A {
int ch[10001000][2], fail[10001000], end[10001000], cnt;
inline int insert(char *s, int id, int *dis) {
  int len = strlen(s), rt = 0;
  for (int i = 0; i < len; ++i) {
    int d = s[i] - 'a';
    if (!ch[rt][d]) ch[rt][d] = ++cnt;
    rt = ch[rt][d];
  }
  if (end[rt]) dis[end[rt]] = 1;
  end[rt] = id;
  return len;
}
void getfail(int dis[1600][1600]) {
  queue<int> q;
  if (ch[0][0]) q.push(ch[0][0]);
  if (ch[0][1]) q.push(ch[0][1]);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int k = 0; k <= 1; ++k) {
      if (!ch[u][k])
        ch[u][k] = ch[fail[u]][k];
      else {
        fail[ch[u][k]] = ch[fail[u]][k];
        if (end[fail[ch[u][k]]]) {
          if (end[ch[u][k]])
            dis[end[ch[u][k]]][end[fail[ch[u][k]]]] = 1;
          else
            end[ch[u][k]] = end[fail[ch[u][k]]];
        }
        q.push(ch[u][k]);
      }
    }
  }
}
void match(char *s, int len, int *dis) {
  int rt = 0;
  for (int i = 0; i < len; ++i) {
    rt = ch[rt][s[i] - 'a'];
    if (end[rt]) dis[end[rt]] = 1;
  }
}
};  // namespace A
int n, st[1600], dis[1600][1600];
char s[10001000];
namespace D {
int S, T, tot = 1, fir[1600], nxt[1600 * 1600], to[1600 * 1600],
          val[1600 * 1600], dep[1600], cur[1600];
queue<int> q;
inline void addE(int u, int v, int w) {
  nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v, val[tot] = w;
  nxt[++tot] = fir[v], fir[v] = tot, to[tot] = u, val[tot] = 0;
}
inline bool bfs() {
  memset(dep, -1, sizeof dep);
  memcpy(cur, fir, sizeof fir);
  q.push(S), dep[S] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = fir[u], v; i; i = nxt[i]) {
      v = to[i];
      if ((~dep[v]) || !val[i]) continue;
      dep[v] = dep[u] + 1, q.push(v);
    }
  }
  return (~dep[T]);
}
int dfs(int u, int now) {
  if (u == T || !now) return now;
  int res = 0;
  for (int &i = cur[u], v; i; i = nxt[i]) {
    v = to[i];
    if (dep[v] != dep[u] + 1 || !val[i]) continue;
    int tmp = dfs(v, min(now, val[i]));
    if (!tmp) continue;
    res += tmp, now -= tmp, val[i] -= tmp, val[i ^ 1] += tmp;
    if (!now) break;
  }
  return res;
}
inline int dinic() {
  int res = 0, tmp;
  while (bfs())
    while ((tmp = dfs(S, INF))) res += tmp;
  return res;
}
int mat[1600];
bool vis[1600];
void match(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int i = fir[u]; i; i = nxt[i])
    if (!vis[to[i]] && to[i] <= 2 * n) vis[to[i]] = 1, match(mat[to[i]]);
}
void write() {
  for (int u = 1; u <= n; ++u)
    for (int i = fir[u]; i && !mat[u]; i = nxt[i])
      if (!val[i] && to[i] <= 2 * n) mat[mat[u] = to[i]] = u;
  for (int u = 1; u <= n; ++u)
    if (!mat[u]) match(u);
  for (int i = 1; i <= n; ++i) {
    if (vis[i] && !vis[i + n]) printf("%d%c", i, " \n"[i == n]);
  }
}
}  // namespace D
using D::addE;
using D::dinic;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + st[i]);
    st[i + 1] = A::insert(s + st[i], i, dis[i]) + st[i];
  }
  A::getfail(dis);
  for (int i = 1; i <= n; ++i) A::match(s + st[i], st[i + 1] - st[i], dis[i]);
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (dis[i][k] && dis[k][j]) dis[i][j] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (dis[i][j]) D::S = 2 * n + 1, D::T = D::S + 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (dis[i][j] && i != j) addE(i, j + n, 1);
  for (int i = 1; i <= n; ++i) addE(D::S, i, 1), addE(i + n, D::T, 1);
  int res = dinic();
  res = n - res;
  cout << res << endl;
  D::write();
  return 0;
}