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>
namespace modular {
const int MOD = 1000000007;
inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
inline int mul(int x, int y) { return 1LL * x * y % MOD; }
inline int qpow(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) ans = mul(ans, x);
  return ans;
}
};  // namespace modular
namespace Base {
template <typename Tp>
inline Tp input() {
  Tp x = 0, y = 1;
  char c = getchar();
  while ((c < '0' || '9' < c) && c != EOF) {
    if (c == '-') y = -1;
    c = getchar();
  }
  if (c == EOF) return 0;
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x *= y;
}
template <typename Tp>
inline void read(Tp &x) {
  x = input<Tp>();
}
template <typename Tp>
inline void chmax(Tp &x, Tp y) {
  x < y ? x = y : 0;
}
template <typename Tp>
inline void chmin(Tp &x, Tp y) {
  x > y ? x = y : 0;
}
};  // namespace Base
using namespace Base;
int N;
int lmc[757], rmc[757];
bool g[757][757], vis[757], lvis[757], rvis[757];
char s[10000007];
std::string str[757];
struct ACAM {
  int sz, ch[10000007][2], fail[10000007], id[10000007];
  std::queue<int> q;
  void ins(char *s, int len, int pos) {
    int p = 0, c;
    for (int i = 1; i <= len; ++i) {
      c = s[i] - 'a';
      if (!ch[p][c]) ch[p][c] = ++sz;
      p = ch[p][c];
    }
    id[p] = pos;
  }
  void getfail() {
    for (int i = 0; i < 2; ++i) {
      if (ch[0][i]) {
        fail[ch[0][i]] = 0;
        q.push(ch[0][i]);
      }
    }
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < 2; ++i) {
        if (!ch[x][i]) {
          ch[x][i] = ch[fail[x]][i];
          continue;
        }
        int j = fail[x];
        while (j && !ch[j][i]) j = fail[j];
        fail[ch[x][i]] = ch[j][i];
        if (!id[ch[x][i]]) id[ch[x][i]] = id[fail[ch[x][i]]];
        q.push(ch[x][i]);
      }
    }
  }
  void addedge(int pos) {
    int p = 0;
    for (char c : str[pos]) {
      p = ch[p][c - 'a'];
      if (id[p]) g[pos][id[p]] = true;
      if (id[fail[p]]) g[pos][id[fail[p]]] = true;
    }
  }
} tr;
bool dfs(int x) {
  for (int i = 1; i <= N; ++i)
    if (g[x][i] && !vis[i]) {
      vis[i] = true;
      if (!rmc[i] || dfs(rmc[i])) {
        rmc[i] = x, lmc[x] = i;
        return true;
      }
    }
  return false;
}
void dfs2(int x) {
  rvis[x] = true;
  for (int i = 1; i <= N; ++i)
    if (g[i][x] && !lvis[i]) lvis[i] = true, dfs2(lmc[i]);
}
int main() {
  read(N);
  for (int i = 1; i <= N; ++i) {
    scanf("%s", s + 1);
    tr.ins(s, strlen(s + 1), i);
    str[i] = s + 1;
  }
  tr.getfail();
  for (int i = 1; i <= N; ++i) tr.addedge(i);
  for (int k = 1; k <= N; ++k)
    for (int i = 1; i <= N; ++i)
      for (int j = 1; j <= N; ++j) g[i][j] |= g[i][k] & g[k][j];
  for (int i = 1; i <= N; ++i) g[i][i] = false;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) vis[j] = false;
    ans += dfs(i);
  }
  printf("%d\n", N - ans);
  for (int i = 1; i <= N; ++i)
    if (!rmc[i]) dfs2(i);
  for (int i = 1; i <= N; ++i)
    if (!lvis[i] && rvis[i]) printf("%d ", i);
  puts("");
  return 0;
}