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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 100010;
const int INF = 2147483600;
const int MAXM = 10000010;
int N;
int ch[MAXM + 1][2];
bitset<810> E[810];
int fa[MAXN + 1], vis[MAXN + 1], tim;
vector<int> V[MAXN + 1];
int Las[MAXM + 1], ed[MAXM + 1], fail[MAXM + 1];
inline bool dfs(int k) {
  if (vis[k] == tim) return 0;
  vis[k] = tim;
  for (int i = 0, sz = V[k].size(); i < sz; i++) {
    int v = V[k][i];
    if (!fa[v] || dfs(fa[v])) {
      fa[v] = k;
      fa[k] = v;
      return 1;
    }
  }
  return 0;
}
inline void dfs2(int k) {
  if (vis[k] == tim) return;
  vis[k] = tim;
  for (int i = 0, sz = V[k].size(); i < sz; i++) {
    int v = V[k][i];
    if (fa[v]) vis[v] = tim, dfs2(fa[v]);
  }
}
int Ans[MAXN + 1], top;
char str[MAXM + 1];
string s[MAXN + 1];
int nod;
int main() {
  N = read();
  for (int i = 1; i <= N; i++) {
    scanf("%s", str + 1);
    int len = strlen(str + 1), k = 0;
    for (int j = 1; j <= len; j++) {
      int c = str[j] - 'a';
      if (!ch[k][c]) ch[k][c] = ++nod;
      k = ch[k][c];
    }
    if (ed[k]) E[i][ed[k]] = 1;
    ed[k] = i;
    for (int j = 1; j <= len; j++) s[i] += (char)str[j];
  }
  queue<int> que;
  for (int i = 0; i < 2; i++)
    if (ch[0][i]) que.push(ch[0][i]), Las[ch[0][i]] = ed[ch[0][i]];
  while (!que.empty()) {
    int k = que.front();
    que.pop();
    for (int i = 0; i < 2; i++) {
      int x = ch[k][i];
      if (!x)
        ch[k][i] = ch[fail[k]][i];
      else
        fail[ch[k][i]] = ch[fail[k]][i], que.push(ch[k][i]),
        Las[ch[k][i]] = (ed[ch[k][i]] ? ed[ch[k][i]] : Las[fail[ch[k][i]]]);
    }
  }
  for (int i = 1; i <= N; i++) {
    int len = s[i].length(), x = 0;
    for (int j = 1; j <= len; j++) {
      x = ch[x][(int)(s[i][j - 1] - 'a')];
      if (j == len) {
        if (Las[fail[x]]) E[i][Las[fail[x]]] = 1;
      } else
        E[i][Las[x]] = 1;
    }
  }
  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][j] | (E[i][k] & E[k][j]);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (E[i][j]) V[i].push_back(j + N), V[j + N].push_back(i);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ++tim;
    if (!fa[i] && dfs(i)) ans++;
  }
  ++tim;
  for (int i = 1; i <= N; i++)
    if (!fa[i]) dfs2(i);
  for (int i = 1; i <= N; i++)
    if (vis[i] == tim && vis[i + N] != tim) Ans[++top] = i;
  printf("%d\n", top);
  for (int i = 1; i <= top; i++) printf("%d ", Ans[i]);
  return 0;
}