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>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int MOD = 1e9 + 7;
const int MAXLEN = 10001000;
char str[MAXLEN];
struct node {
  int go[2];
  int tr, nr, p, suf, sym;
  node() {
    tr = nr = p = -1;
    suf = 0;
    go[0] = go[1] = sym = 0;
  }
};
node mem[MAXLEN];
int nowmem = 1;
int newn() { return nowmem++; }
void add(char *s, int x) {
  int n = strlen(s);
  int now = 0;
  for (int i = 0; i < n; ++i) {
    if (mem[now].go[s[i] - 'a'])
      now = mem[now].go[s[i] - 'a'];
    else {
      int y = newn();
      mem[y].p = now;
      mem[y].sym = s[i] - 'a';
      now = mem[now].go[s[i] - 'a'] = y;
    }
  }
  mem[now].tr = x;
}
void calc(int x) {
  if (!x) return;
  if (mem[x].p == 0)
    mem[x].suf = 0;
  else
    mem[x].suf = mem[mem[mem[x].p].suf].go[mem[x].sym];
  if (mem[mem[x].suf].tr != -1)
    mem[x].nr = mem[mem[x].suf].tr;
  else
    mem[x].nr = mem[mem[x].suf].nr;
  for (int i = 0; i < 2; ++i) {
    if (!mem[x].go[i]) mem[x].go[i] = mem[mem[x].suf].go[i];
  }
}
void build_ak() {
  queue<int> qu;
  qu.push(0);
  while (!qu.empty()) {
    int x = qu.front();
    qu.pop();
    for (int i = 0; i < 2; ++i)
      if (mem[x].go[i]) qu.push(mem[x].go[i]);
    calc(x);
  }
}
const int N = 760;
int gr[N][N];
int gr2[N][N];
int usss[N];
int n;
void dfs(int v, int nc) {
  usss[v] = 1;
  for (int i = 0; i < n; i++) {
    if (gr[v][i] && v != i && !usss[i]) {
      dfs(i, nc);
    }
  }
}
vector<int> mt;
vector<char> used;
bool try_kuhn(int v) {
  if (used[v]) return false;
  used[v] = true;
  for (size_t i = 0; i < n; ++i) {
    int to = gr[v][i];
    if (to) {
      to = i;
      if (mt[to] == -1 || try_kuhn(mt[to])) {
        mt[to] = v;
        return true;
      }
    }
  }
  return false;
}
int us[N * 2];
char *s[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  scanf("%d", &n);
  char *s2 = str;
  for (int i = 0; i < n; ++i) {
    scanf(" %s", s2);
    s[i] = s2;
    s2 += strlen(s2) + 1;
  }
  for (int i = 0; i < n; ++i) add(s[i], i);
  build_ak();
  for (int i = 0; i < n; ++i) {
    int now = 0;
    int l = strlen(s[i]);
    for (int j = 0; j < l; ++j) {
      now = mem[now].go[s[i][j] - 'a'];
      if (mem[now].nr != -1) gr[mem[now].nr][i] = 1;
      if (mem[now].tr != -1 && j != l - 1) gr[mem[now].tr][i] = 1;
    }
  }
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (gr[i][k] && gr[k][j]) gr[i][j] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (gr[i][j] && gr[j][i]) {
        gr[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    dfs(i, i);
    for (int j = 0; j < n; j++) {
      if (usss[j]) {
        gr[i][j] = 1;
        usss[j] = 0;
      }
    }
  }
  int gv[n];
  for (int i = 0; i < n; i++) {
    gr[i][i] = 0;
    gv[i] = 0;
    for (int j = 0; j < n; j++) {
      gv[i] += gr[i][j];
    }
  }
  mt.assign(n, -1);
  for (int v = 0; v < n; ++v) {
    used.assign(n, false);
    try_kuhn(v);
  }
  vector<int> anss(n * 2);
  int kol = 0;
  int lel = 0;
  for (int i = 0; i < n; i++) {
    if (mt[i] != -1) {
      lel++;
      gr2[mt[i]][i] = 1;
      gr[mt[i]][i] = 0;
      anss[i + n] = 1;
      anss[mt[i]] = 1;
    }
  }
  queue<pair<int, int> > qq;
  for (int i = 0; i < n * 2; i++) {
    if (!anss[i]) {
      qq.push({i, 1});
      us[i] = 1;
    }
  }
  int lst = 1;
  while (qq.size()) {
    while (qq.size()) {
      auto v = qq.front();
      lst = v.second;
      qq.pop();
      if (v.first >= n) {
        if (v.second == 1) {
          for (int i = 0; i < n; i++) {
            if (gr[i][v.first - n] && !us[i]) {
              qq.push({i, 2});
              us[i] = 2;
            }
          }
        } else {
          for (int i = 0; i < n; i++) {
            if (gr2[i][v.first - n] && !us[i]) {
              qq.push({i, 1});
              us[i] = 1;
            }
          }
        }
        continue;
      }
      if (v.second == 1) {
        for (int i = 0; i < n; i++) {
          if (gr[v.first][i] && !us[i + n]) {
            qq.push({i + n, 2});
            us[i + n] = 2;
          }
        }
      } else {
        for (int i = 0; i < n; i++) {
          if (gr2[v.first][i] && !us[i + n]) {
            qq.push({i + n, 1});
            us[i + n] = 1;
          }
        }
      }
    }
    for (int i = 0; i < n * 2; i++) {
      if (!us[i]) {
        qq.push({i, 2});
        us[i] = 2;
        break;
      }
    }
  }
  vector<int> penis(n);
  for (int i = 0; i < 2 * n; i++) {
    if (us[i] == 2) {
      int kek = 0;
      if (i >= n) kek += n;
      penis[i - kek] = 1;
    }
  }
  vector<int> pn2;
  for (int i = 0; i < n; i++) {
    if (!penis[i]) {
      pn2.push_back(i);
    }
  }
  cout << n - lel << endl;
  for (auto i : pn2) {
    cout << i + 1 << " ";
  }
}