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;
string str[755];
int n, ans[755], ch[10000005][2], tot, fa[10000005], fail[10000005],
    wch[10000005], d[755][755];
bool vis[1505];
void insert(int id) {
  int now = 0, m = str[id].size();
  for (int i = 0; i < m; i++) {
    int c = str[id][i] - 'a';
    if (!ch[now][c]) ch[now][c] = ++tot;
    now = ch[now][c];
  }
  fa[now] = now;
  wch[now] = id;
}
template <unsigned N, unsigned M>
struct Maxflow {
  int const inf = 1e9;
  int maxflow, s, t, tot = 1, target[M], pre[M], last[N], cap[M], deep[N],
                     cur[N];
  queue<int> q;
  void add(int x, int y, int z) {
    target[++tot] = y;
    pre[tot] = last[x];
    last[x] = tot;
    cap[tot] = z;
    target[++tot] = x;
    pre[tot] = last[y];
    last[y] = tot;
  }
  bool bfs() {
    for (int i = s; i <= t; i++) deep[i] = 0, cur[i] = last[i];
    q.push(s);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (int i = last[now]; i; i = pre[i]) {
        int tar = target[i];
        if (tar != s && cap[i] && (!deep[tar]))
          deep[tar] = deep[now] + 1, q.push(tar);
      }
    }
    return deep[t];
  }
  int dfs(int x, int lim) {
    if ((!lim) || x == t) return lim;
    int flow = 0;
    for (int i = cur[x]; i; cur[x] = i, i = pre[i]) {
      int tar = target[i];
      if (cap[i] && deep[tar] == deep[x] + 1) {
        int d = dfs(tar, min(lim, cap[i]));
        cap[i] -= d;
        cap[i ^ 1] += d;
        lim -= d;
        flow += d;
        if (!lim) break;
      }
    }
    return flow;
  }
  void dfs2(int x) {
    vis[x] = 1;
    for (int i = last[x]; i; i = pre[i]) {
      int tar = target[i];
      if (tar == s || tar == t || vis[tar] || cap[i]) continue;
      dfs2(tar);
    }
  }
  void dinic() {
    while (bfs()) maxflow += dfs(s, inf);
  }
  void work() {
    for (int i = n + 1; i <= 2 * n; i++) {
      bool flag = 0;
      for (int j = last[i]; j; j = pre[j])
        if (target[j] == t && cap[j]) {
          flag = 1;
          break;
        }
      if (!flag) continue;
      dfs2(i);
    }
    for (int i = 1; i <= n; i++)
      if ((!vis[i]) && vis[i + n]) ans[i] = 1;
  }
};
Maxflow<1505, 5000005> g;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
    insert(i);
  }
  queue<int> q;
  for (int i = 0; i <= 1; i++)
    if (ch[0][i]) q.push(ch[0][i]);
  while (q.size()) {
    int now = q.front();
    q.pop();
    if (!wch[now]) fa[now] = fa[fail[now]];
    for (int i = 0; i <= 1; i++)
      if (ch[now][i])
        fail[ch[now][i]] = ch[fail[now]][i], q.push(ch[now][i]);
      else
        ch[now][i] = ch[fail[now]][i];
  }
  for (int i = 1; i <= n; i++) {
    int now = 0;
    for (int j = 0; j < str[i].size(); j++) {
      if (wch[now]) d[i][wch[now]] = 1;
      now = ch[now][str[i][j] - 'a'];
      d[i][wch[fa[fail[now]]]] = 1;
    }
  }
  for (int k = 1; k <= n; k++) d[k][k] = 1;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) d[i][j] |= (d[i][k] && d[k][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j && d[i][j]) g.add(i, j + n, 1);
  g.t = 2 * n + 1;
  for (int i = 1; i <= n; i++) g.add(0, i, 1), g.add(i + n, g.t, 1);
  g.dinic();
  printf("%d\n", n - g.maxflow);
  g.work();
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", i);
  return 0;
}