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 = 1e7 + 50;
const int NN = 760;
char s[N];
int nx[N][2], To[N], id[N], fl[N], cnt = 1, n;
int st[NN], ed[NN], mt[NN];
bool mp[NN][NN], vis[NN], tag[NN], use[NN][2];
queue<int> q;
void ins(int st, int l, int ID) {
  int nw = 1;
  for (int i = st; i <= st + l - 1; i++) {
    int ch = s[i] - 'a';
    if (!nx[nw][ch]) nx[nw][ch] = ++cnt;
    nw = nx[nw][ch];
  }
  id[nw] = ID;
}
void getf() {
  q.push(1);
  fl[1] = 1;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (id[fl[t]])
      To[t] = fl[t];
    else
      To[t] = To[fl[t]];
    for (int i = 0; i <= 1; i++)
      if (nx[t][i]) {
        q.push(nx[t][i]);
        fl[nx[t][i]] = t == 1 ? 1 : nx[fl[t]][i];
      } else {
        nx[t][i] = t == 1 ? 1 : nx[fl[t]][i];
      }
  }
}
void build() {
  for (int i = 1; i <= n; i++) {
    for (int nw = 1, j = st[i]; j <= ed[i]; ++j) {
      int ch = s[j] - 'a';
      nw = nx[nw][ch];
      for (int t = id[nw] ? nw : To[nw]; t && !mp[i][id[t]]; t = To[t])
        mp[i][id[t]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) mp[i][i] = 0;
}
bool efind(int x) {
  for (int i = 1; i <= n; i++)
    if (mp[x][i] && !vis[i]) {
      vis[i] = 1;
      if (!mt[i] || efind(mt[i])) {
        mt[i] = x;
        return 1;
      }
    }
  return 0;
}
void mark(int x) {
  if (use[x][0]) return;
  use[x][0] = 1;
  for (int i = 1; i <= n; i++)
    if (mp[x][i] && !use[i][1]) {
      use[i][1] = 1;
      mark(mt[i]);
    }
}
void solve() {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    if (efind(i))
      ++ans;
    else
      tag[i] = 1;
  }
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; i++)
    if (tag[i]) mark(i);
  for (int i = 1; i <= n; i++) {
    if (use[i][0] && !use[i][1]) printf("%d ", i);
  }
  puts("");
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    st[i] = ed[i - 1] + 1;
    scanf("%s", s + st[i]);
    int l = strlen(s + st[i]);
    ins(st[i], l, i);
    ed[i] = ed[i - 1] + l;
  }
  getf();
  build();
  solve();
  return 0;
}