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>
const int oo = 0x3f3f3f3f;
template <typename T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <typename T>
T read(T &first) {
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (first = 0; isdigit(ch); ch = getchar()) first = 10 * first + ch - '0';
  return first *= f;
}
template <typename T>
void write(T first) {
  if (first == 0) {
    putchar('0');
    return;
  }
  if (first < 0) {
    putchar('-');
    first = -first;
  }
  static char s[20];
  int top = 0;
  for (; first; first /= 10) s[++top] = first % 10 + '0';
  while (top) putchar(s[top--]);
}
const int MAXN = 755, MAXL = 1e7 + 5;
int N;
char mempool[MAXL];
char *S[MAXN];
int len[MAXN];
int G[MAXN][MAXN];
namespace ACAutomata {
const int SIZE = MAXL;
const int SIGMA = 2;
int size, ch[SIZE][SIGMA];
int id[SIZE];
int fail[SIZE], last[SIZE];
inline void init() { size = 1; }
void insert(const char *s, int n, int id0) {
  int u = 1;
  for (int i = 0; i < n; ++i) {
    int first = s[i] - 'a';
    if (ch[u][first] == 0) ch[u][first] = ++size;
    u = ch[u][first];
  }
  id[u] = id0;
}
void build() {
  static int q[SIZE];
  int front = 0, rear = 0;
  for (int i = 0; i < SIGMA; ++i) {
    int u = ch[1][i];
    if (u) {
      fail[u] = 1;
      q[rear++] = u;
    }
  }
  while (front != rear) {
    int u = q[front++];
    for (int i = 0; i < SIGMA; ++i) {
      int &v = ch[u][i];
      if (v == 0)
        v = ch[fail[u]][i];
      else {
        fail[v] = ch[fail[u]][i];
        last[v] = id[fail[v]] ? fail[v] : last[fail[v]];
        q[rear++] = v;
      }
    }
  }
}
void getEdge(const char *s, int n, int cur) {
  int u = 1;
  for (int i = 0; i < n; ++i) {
    int first = s[i] - 'a';
    if (id[u]) G[id[u]][cur] = true;
    for (int p = last[u]; p && !G[id[p]][cur]; p = last[p]) {
      G[id[p]][cur] = true;
    }
    u = ch[u][first];
  }
  for (int p = last[u]; p && !G[id[p]][cur]; p = last[p]) {
    G[id[p]][cur] = true;
  }
}
}  // namespace ACAutomata
namespace Hungary {
int match[MAXN];
bool vis[MAXN], matx[MAXN];
bool fx[MAXN], fy[MAXN];
bool dfs(int u) {
  for (int v = 1; v <= N; ++v) {
    if (G[u][v] && !vis[v]) {
      vis[v] = true;
      if (match[v] == 0 || dfs(match[v])) {
        match[v] = u;
        return true;
      }
    }
  }
  return false;
}
void dfs0(int u) {
  if (fx[u]) return;
  fx[u] = true;
  for (int v = 1; v <= N; ++v) {
    if (G[u][v] && fy[v]) {
      fy[v] = false;
      if (match[v]) dfs0(match[v]);
    }
  }
}
int exec() {
  int ret = 0;
  for (int i = 1; i <= N; ++i) {
    memset(vis, 0, sizeof(vis));
    if (dfs(i)) {
      matx[i] = true;
      ++ret;
    }
  }
  memset(fx, 0, sizeof(fx));
  std::fill(fy + 1, fy + N + 1, true);
  for (int i = 1; i <= N; ++i) {
    if (!matx[i]) dfs0(i);
  }
  return ret;
}
}  // namespace Hungary
void input() {
  read(N);
  S[0] = mempool;
  ACAutomata::init();
  for (int i = 1; i <= N; ++i) {
    S[i] = S[i - 1] + len[i - 1];
    scanf("%s", S[i]);
    len[i] = strlen(S[i]);
    ACAutomata::insert(S[i], len[i], i);
  }
}
void solve() {
  ACAutomata::build();
  for (int i = 1; i <= N; ++i) {
    ACAutomata::getEdge(S[i], len[i], 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];
      }
    }
  }
  int ans = N - Hungary::exec();
  write(ans);
  putchar('\n');
  for (int i = 1; i <= N; ++i) {
    if (Hungary::fx[i] && Hungary::fy[i]) {
      write(i);
      putchar(' ');
    }
  }
  putchar('\n');
}
int main() {
  input();
  solve();
  return 0;
}