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;
int n;
char s[10000010];
struct Trie {
  struct nd {
    int ch[2], fa, fail, pos;
  } t[10000010];
  int used;
  Trie() : used(1) {}
  int id[10000010];
  int ins(int len, int I) {
    int u = 1;
    for (int i = 1; i <= len; i++) {
      if (!t[u].ch[s[i] - 'a'])
        t[u].ch[s[i] - 'a'] = ++used, t[t[u].ch[s[i] - 'a']].fa = u;
      u = t[u].ch[s[i] - 'a'];
    }
    id[u] = I;
    return u;
  }
  void build() {
    queue<int> q;
    for (int j = 0; j < 2; j++)
      if (t[1].ch[j]) {
        t[t[1].ch[j]].fail = 1;
        q.push(t[1].ch[j]);
      }
    while (!q.empty()) {
      int i = q.front();
      q.pop();
      if (id[i])
        t[i].pos = id[i];
      else
        t[i].pos = t[t[i].fail].pos;
      for (int j = 0; j < 2; j++) {
        if (t[i].ch[j])
          t[t[i].ch[j]].fail = t[t[i].fail].ch[j], q.push(t[i].ch[j]);
        else
          t[i].ch[j] = t[t[i].fail].ch[j];
      }
    }
  }
} T;
int r[1000];
bool e[1000][1000];
void add(int i) {
  int p = r[i];
  if (T.t[T.t[p].fail].pos) {
    e[T.t[T.t[p].fail].pos][i] = 1;
  }
  p = T.t[p].fa;
  while (p) {
    if (T.t[p].pos) {
      e[T.t[p].pos][i] = 1;
    }
    p = T.t[p].fa;
  }
}
int cp[1000];
bool vis[1000];
vector<int> pth[1000];
int fnd(int x) {
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && e[x][i]) {
      vis[i] = 1;
      if (!cp[i] || fnd(cp[i])) {
        cp[i] = x;
        return 1;
      }
    }
  }
  return 0;
}
int id[1000];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    int m = strlen(s + 1);
    r[i] = T.ins(m, i);
  }
  T.build();
  for (int i = 1; i <= n; i++) add(i);
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) e[i][j] |= (e[i][k] & e[k][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    fnd(i);
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++)
    if (cp[i]) vis[cp[i]] = 1;
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      c++;
      int x = i;
      pth[c].push_back(x);
      while (cp[x]) {
        x = cp[x];
        pth[c].push_back(x);
      }
      reverse(pth[c].begin(), pth[c].end());
    }
  }
  for (int i = 1; i <= c; i++) id[i] = pth[i].size() - 1;
  while (1) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= c; i++) {
      int u = pth[i][id[i]];
      for (int j = 1; j <= n; j++)
        if (e[u][j]) vis[j] = 1;
    }
    bool fl = 1;
    for (int i = 1; i <= c; i++)
      if (vis[pth[i][id[i]]]) {
        fl = 0;
        break;
      }
    if (fl) break;
    for (int i = 1; i <= c; i++) {
      while (vis[pth[i][id[i]]]) id[i]--;
    }
  }
  printf("%d\n", c);
  for (int i = 1; i <= c; i++) printf("%d ", pth[i][id[i]]);
}