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;
template <class T>
inline void gmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void gmax(T &x, const T &y) {
  if (x < y) x = y;
}
const int BufferSize = 1 << 16;
char buffer[BufferSize], *Bufferhead, *Buffertail;
bool Terminal;
inline char Getchar() {
  if (Bufferhead == Buffertail) {
    int l = fread(buffer, 1, BufferSize, stdin);
    if (!l) {
      Terminal = 1;
      return 0;
    }
    Buffertail = (Bufferhead = buffer) + l;
  }
  return *Bufferhead++;
}
template <class T>
inline bool read(T &x) {
  x = 0;
  char c = Getchar(), rev = 0;
  while (c < '0' || c > '9') {
    c = Getchar();
    rev |= c == '-';
    if (Terminal) return 0;
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = Getchar();
  if (c == '.') {
    c = Getchar();
    double t = 0.1;
    while (c >= '0' && c <= '9')
      x = x + (c - '0') * t, c = Getchar(), t = t / 10;
  }
  x = rev ? -x : x;
  return 1;
}
template <class T1, class T2>
inline bool read(T1 &x, T2 &y) {
  return read(x) & read(y);
}
template <class T1, class T2, class T3>
inline bool read(T1 &x, T2 &y, T3 &z) {
  return read(x) & read(y) & read(z);
}
template <class T1, class T2, class T3, class T4>
inline bool read(T1 &x, T2 &y, T3 &z, T4 &w) {
  return read(x) & read(y) & read(z) & read(w);
}
inline bool reads(char *x) {
  char c = Getchar();
  while (c < 33 || c > 126) {
    c = Getchar();
    if (Terminal) return 0;
  }
  while (c >= 33 && c <= 126) (*x++) = c, c = Getchar();
  *x = 0;
  return 1;
}
template <class T>
inline void print(T x, const char c = '\n') {
  if (!x) {
    putchar('0');
    putchar(c);
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int m = 0, a[20];
  while (x) a[m++] = x % 10, x /= 10;
  while (m--) putchar(a[m] + '0');
  putchar(c);
}
const int inf = 0x3f3f3f3f;
const int N = 755, M = 10000005, mod = 1e9 + 7;
template <class T, class S>
inline void ch(T &x, const S y) {
  x = (x + y) % mod;
}
inline int exp(int x, int y, const int mod = ::mod) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
queue<int> q;
int n, ans, mx[N], my[N], __end[N];
bool g[N][N], vis[N], mark[N][2];
int cnt, a[M][2], p[M], fail[M], tag[M];
char str[M];
bool dfs(int x) {
  for (int y = 1; y <= n; y++) {
    if (vis[y] || !g[x][y]) continue;
    vis[y] = 1;
    if (!my[y] || dfs(my[y])) {
      my[y] = x;
      mx[x] = y;
      return 1;
    }
  }
  return 0;
}
void dfs(int x, int k) {
  if (mark[x][k]) return;
  mark[x][k] = 1;
  if (k)
    dfs(my[x], 0);
  else {
    for (int y = 1; y <= n; y++)
      if (g[x][y]) dfs(y, 1);
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    reads(str);
    int l = strlen(str), k = 0;
    for (int j = 0; j < l; j++) {
      if (!a[k][str[j] - 'a']) a[k][str[j] - 'a'] = ++cnt, p[cnt] = k;
      k = a[k][str[j] - 'a'];
    }
    tag[k] = i;
    __end[i] = k;
  }
  q.push(0);
  while (!q.empty()) {
    int k = q.front();
    q.pop();
    if (!tag[k]) tag[k] = tag[fail[k]];
    for (int c = 0; c < 2; c++) {
      if (!a[k][c]) continue;
      q.push(a[k][c]);
      if (!k) {
        fail[a[k][c]] = 0;
        continue;
      }
      int t = fail[k];
      while (t && !a[t][c]) t = fail[t];
      fail[a[k][c]] = a[t][c];
    }
  }
  for (int i = 1; i <= n; i++) {
    int k = __end[i];
    while (k) g[i][tag[k]] = 1, g[i][tag[fail[k]]] = 1, k = p[k];
    g[i][i] = 0;
  }
  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++, fprintf(stderr, "\n"))
    for (int j = 1; j <= n; j++) fprintf(stderr, "%d", g[i][j]);
  for (int i = 1; i <= n; i++) memset(vis, 0, sizeof(vis)), ans += dfs(i);
  for (int i = 1; i <= n; i++)
    if (!mx[i]) dfs(i, 0);
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; i++)
    if (mark[i][0] && !mark[i][1]) printf("%d ", i);
  puts("");
  return 0;
}