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;
struct edge {
  int v, nxt, c;
} e[1505 * 1505 * 2];
int p[1505], eid;
void init() {
  memset(p, -1, sizeof p);
  eid = 0;
}
void insert(int u, int v, int c) {
  e[eid].v = v;
  e[eid].c = c;
  e[eid].nxt = p[u];
  p[u] = eid++;
}
void add(int u, int v, int c) {
  insert(u, v, c);
  insert(v, u, 0);
}
int ch[10000005][2], cnt[10000005], tot, ys[1505], nxt[10000005], g[755][755],
    L[1505], R[1505], ha[10000005];
string st;
queue<int> q;
void insert(int id) {
  int p = 0, len = st.length();
  L[id] = ha[0] + 1;
  for (int i = 0; i < len; i++) {
    ha[++ha[0]] = st[i] - 'a';
    if (!ch[p][st[i] - 'a']) ch[p][st[i] - 'a'] = ++tot;
    p = ch[p][st[i] - 'a'];
  }
  cnt[p] = id;
  R[id] = ha[0];
}
void build() {
  for (int i = 0; i < 2; i++)
    if (ch[0][i]) q.push(ch[0][i]);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 2; i++) {
      if (!ch[u][i])
        ch[u][i] = ch[nxt[u]][i];
      else
        nxt[ch[u][i]] = ch[nxt[u]][i], q.push(ch[u][i]);
    }
  }
}
int vis[10000005];
void run(int id) {
  int p = 0;
  vis[0] = 1;
  for (int i = L[id]; i <= R[id]; i++) {
    p = ch[p][ha[i]];
    int pp = p, tt;
    while (pp) {
      if (cnt[pp] && cnt[pp] != id) {
        g[id][cnt[pp]] = 1;
        break;
      }
      pp = nxt[pp];
    }
    int haha = pp;
    pp = p;
    while (pp) {
      if (cnt[pp] && cnt[pp] != id) {
        break;
      }
      tt = pp;
      pp = nxt[pp];
      nxt[tt] = haha;
    }
  }
}
int dis[1505], S, T, n;
int bfs() {
  memset(dis, -1, sizeof dis);
  dis[S] = 1;
  q.push(S);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = p[u]; i + 1; i = e[i].nxt) {
      int v = e[i].v;
      if (dis[v] == -1 && e[i].c) {
        dis[v] = dis[u] + 1;
        q.push(v);
      }
    }
  }
  return dis[T] != -1;
}
int dfs(int u, int flow) {
  if (u == T) return flow;
  int ret = 0;
  for (int i = p[u]; i + 1; i = e[i].nxt) {
    int c = e[i].c, v = e[i].v;
    if (c && dis[v] == dis[u] + 1) {
      int tmp = dfs(v, min(flow, c));
      ret += tmp, flow -= tmp;
      e[i].c -= tmp, e[i ^ 1].c += tmp;
      if (!flow) break;
    }
  }
  if (!ret) dis[u] = -1;
  return ret;
}
int Dinic() {
  int ret = 0;
  for (; bfs();) ret += dfs(S, 2147483646 / 2);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  T = 2 * n + 1;
  for (int i = 1; i <= n; i++) cin >> st, insert(i);
  build();
  for (int i = 1; i <= n; i++) run(i);
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) g[i][j] |= (g[i][k] & g[k][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (g[i][j] && i != j) add(i, j + n, 1);
  for (int i = 1; i <= n; i++) add(S, i, 1), add(i + n, T, 1), vis[i + n] = 0;
  cout << n - Dinic() << endl;
  for (int i = 1; i <= n; i++)
    if (dis[i] != -1 && dis[i + n] == -1) cout << i << ' ';
  return 0;
}