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;
char s[10000007];
int n;
int idcnt = 1, ch[10000007][2], fa[10000007], lst[10000007], up[10000007];
int id[10000007], pos[1003];
int res[1003], ans;
int d[1003][1003];
void ins(int id) {
  int p = 1, len = strlen(s + 1);
  for (int i = 1, c; i <= len; ++i) {
    if (!ch[p][c = s[i] == 'a']) up[ch[p][c] = ++idcnt] = p;
    p = ch[p][c];
  }
  (!::id[p]) ? ::id[pos[id] = p] = id : --ans;
}
queue<int> q;
void getfail() {
  if (ch[1][0]) q.push(ch[1][0]), fa[ch[1][0]] = 1;
  if (ch[1][1]) q.push(ch[1][1]), fa[ch[1][1]] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int c = 0, v; c < 2; ++c)
      if (v = ch[u][c]) {
        int p = fa[u];
        while (p && !ch[p][c]) p = fa[p];
        fa[v] = p ? ch[p][c] : 1, q.push(v);
        lst[v] = id[fa[v]] ? id[fa[v]] : lst[fa[v]];
      }
  }
  for (int i = 1; i <= n; ++i) {
    int p = pos[i];
    while (p) d[lst[p]][i] = d[id[p]][i] = 1, p = up[p];
  }
}
void floyd() {
  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) d[i][i] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j)
      if (d[i][j] & d[j][i]) exit(1);
  }
}
bool vis[1003];
int nxt[1003];
bool dfs(int u) {
  for (int v = 1; v <= n; ++v)
    if (!vis[v] && pos[v] && d[u][v]) {
      vis[v] = 1;
      if (!nxt[v] || dfs(nxt[v])) return nxt[v] = u, 1;
    }
  return 0;
}
int main() {
  scanf("%d", &n), ans = n;
  for (int i = 1; i <= n; ++i) scanf("%s", s + 1), ins(i);
  getfail(), floyd();
  for (int i = 1; i <= n; ++i)
    if (pos[i]) ans -= dfs(i), memset(vis, 0, sizeof vis);
  int tans = ans;
  printf("%d\n", ans);
  ans = 0;
  for (int i = 1; i <= n; ++i)
    if (pos[i]) vis[nxt[i]] = 1;
  for (int i = 1; i <= n; ++i)
    if (pos[i] && !vis[i]) res[++ans] = i;
  if (tans != ans) exit(1);
  memset(vis, 0, sizeof vis);
  while (1) {
    int flg = 0;
    for (int j = 1; j <= n; ++j)
      if (pos[j] && !vis[j])
        for (int i = 1; i <= ans; ++i)
          if (pos[i] && d[res[i]][j]) {
            vis[j] = 1;
            break;
          }
    for (int i = 1; i <= ans; ++i)
      if (vis[res[i]]) {
        flg = 1;
        while (vis[res[i]]) res[i] = nxt[res[i]];
      }
    if (!flg) break;
  }
  for (int i = 1; i <= ans; ++i) printf("%d ", res[i]);
  return 0;
}