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;
const int N = 755, M = 1e7 + 5;
int n, tot, ch[2][M], fail[M], id[M], G[N][N], mat[N << 1], vis[N << 1], tim;
string s[N];
vector<int> e[N << 1];
queue<int> Q;
int dfs(int u) {
  for (int i = 0, sz = e[u].size(); i < sz; ++i) {
    int v = e[u][i];
    if (vis[v] == tim) continue;
    vis[v] = tim;
    if (!mat[v] || dfs(mat[v])) return mat[u] = v, mat[v] = u, 1;
  }
  return 0;
}
void dfs2(int u) {
  vis[u] = tim;
  for (int i = 0, sz = e[u].size(); i < sz; ++i) {
    int v = e[u][i];
    if (mat[v] && vis[v] != tim) vis[v] = tim, dfs2(mat[v]);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    int x = 0;
    for (int j = 0, l = s[i].length(); j < l; ++j) {
      if (!ch[s[i][j] - 'a'][x]) ch[s[i][j] - 'a'][x] = ++tot;
      x = ch[s[i][j] - 'a'][x];
    }
    id[x] = i;
  }
  for (int i = 0; i < 2; ++i)
    if (ch[i][0]) Q.push(ch[i][0]);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = 0; i < 2; ++i)
      if (ch[i][u])
        fail[ch[i][u]] = ch[i][fail[u]], Q.push(ch[i][u]);
      else
        ch[i][u] = ch[i][fail[u]];
    if (!id[u]) id[u] = id[fail[u]];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 0, l = s[i].length(), x = 0; j < l; ++j) {
      x = ch[s[i][j] - 'a'][x];
      if (j == l - 1)
        G[i][id[fail[x]]] = 1;
      else
        G[i][id[x]] = 1;
    }
  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)
    for (int j = 1; j <= n; ++j)
      if (G[i][j]) e[i].push_back(j + n), e[j + n].push_back(i);
  int ans = n;
  for (int i = 1; i <= n; ++i)
    if (!mat[i]) ++tim, ans -= dfs(i);
  printf("%d\n", ans);
  ++tim;
  for (int i = 1; i <= n; ++i)
    if (!mat[i]) dfs2(i);
  for (int i = 1; i <= n; ++i)
    if (vis[i] == tim && vis[i + n] != tim) printf("%d ", i);
  puts("");
  return 0;
}