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 N = 2020, M = 755 * 755, L = 1e7 + 5, inf = 1 << 30;
int n, cnt = 1, ans, ch[L][2], fail[L], id[L];
string s[N];
queue<int> q;
bitset<755> b[N];
namespace flow {
int head[N], cur[N], nxt[M], to[M], wei[M], lev[N], tot = 1, s, t;
void addedge(int u, int v, int w = 1) {
  nxt[++tot] = head[u], head[u] = tot, to[tot] = v, wei[tot] = w;
  nxt[++tot] = head[v], head[v] = tot, to[tot] = u, wei[tot] = 0;
}
bool bfs() {
  memset(lev, -1, sizeof(lev));
  queue<int> q;
  q.push(s), lev[s] = 1;
  memcpy(cur, head, sizeof(head));
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int e = head[u]; e; e = nxt[e])
      if (lev[to[e]] == -1 && wei[e]) {
        lev[to[e]] = lev[u] + 1, q.push(to[e]);
        if (to[e] == t) return true;
      }
  }
  return false;
}
int dfs(int u, int mx) {
  if (u == t) return mx;
  int l = mx;
  for (int& e = cur[u]; l && e; e = nxt[e])
    if (wei[e] && lev[to[e]] == lev[u] + 1) {
      int f = dfs(to[e], min(l, wei[e]));
      if (!f) --lev[to[e]];
      l -= f, wei[e] -= f, wei[e ^ 1] += f;
    }
  return mx - l;
}
int dinic() {
  int x = 0;
  while (bfs()) x += dfs(s, inf);
  return x;
}
}  // namespace flow
using flow::addedge;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    int u = 1;
    for (int j = 0; j < s[i].size(); ++j) {
      s[i][j] -= 'a';
      if (!ch[u][s[i][j]]) ch[u][s[i][j]] = ++cnt;
      u = ch[u][s[i][j]];
    }
    id[u] = i;
  }
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (!id[u])
      id[u] = id[fail[u]];
    else if (id[fail[u]])
      b[id[fail[u]]][id[u]] = true;
    for (int i = 0; i < 2; i++) {
      if (!ch[u][i]) {
        ch[u][i] = ch[fail[u]][i];
        continue;
      }
      fail[ch[u][i]] = (fail[u] ? ch[fail[u]][i] : 1);
      q.push(ch[u][i]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    int u = 1;
    for (int j = 0; j < s[i].size(); ++j) {
      u = ch[u][s[i][j]];
      if (id[u] && i != id[u]) b[id[u]][i] = true;
    }
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      if (b[i][k]) b[i] |= b[k];
  flow::s = 2 * n + 1, flow::t = flow::s + 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (b[i][j]) addedge(i, j + n);
  for (int i = 1; i <= n; ++i) addedge(flow::s, i), addedge(i + n, flow::t);
  ans = n - flow::dinic();
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i)
    if (flow::lev[i] != -1 && flow::lev[i + n] == -1) printf("%d ", i);
}