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 maxm = 1e7 + 9;
const int maxn = 2e6 + 9;
const int N = 1000 + 9;
const int mod = 20100403;
const int inf = 0x3f3f3f3f;
const int base = 131;
const double eps = 1e-4;
int n;
struct Edge {
  int come, to, from, flow;
} edge[maxn];
int last[maxn], cnt = 1;
int S, T, tot = 0;
bool dis[N][N];
int dep[maxn], max_flow;
int ans = 0;
bool v1[maxn], v2[maxn];
int link[maxn];
string B[751];
char A[maxm];
int ch[maxm][2], fail[maxm], num = 0, id[maxm];
int read() {
  int a = 1, b = 0;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') a = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    b = (b << 1) + (b << 3) + (c ^ '0');
    c = getchar();
  }
  return a * b;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
inline void add(int x, int y, int z) {
  edge[++cnt].to = y;
  edge[cnt].flow = z;
  edge[cnt].come = x;
  edge[cnt].from = last[x];
  last[x] = cnt;
}
void insert(char *s, int th) {
  int len = strlen(s), now = 0;
  for (int i = (0); i <= (len - 1); ++i) {
    int j = s[i] - 'a';
    if (!ch[now][j]) ch[now][j] = ++num;
    now = ch[now][j];
  }
  id[now] = th;
}
void getfail() {
  queue<int> q;
  fail[0] = 0;
  for (int i = (0); i <= (1); ++i)
    if (ch[0][i]) q.push(ch[0][i]), fail[ch[0][i]] = 0;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = (0); i <= (1); ++i) {
      if (!ch[now][i]) {
        ch[now][i] = ch[fail[now]][i];
        continue;
        ;
      }
      q.push(ch[now][i]);
      int j = fail[now];
      while (j && !ch[j][i]) j = fail[j];
      fail[ch[now][i]] = ch[j][i];
      if (!id[ch[now][i]]) id[ch[now][i]] = id[fail[ch[now][i]]];
    }
  }
}
void find(int x) {
  int len = B[x].length(), now = 0;
  for (int i = (0); i <= (len - 1); ++i) {
    int j = B[x][i] - 'a';
    now = ch[now][j];
    if (id[now]) dis[x][id[now]] = 1;
    if (id[fail[now]]) dis[x][id[fail[now]]] = 1;
  }
}
bool bfs() {
  queue<int> q;
  memset(dep, -1, sizeof(dep));
  q.push(S);
  dep[S] = 0;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = last[now]; i; i = edge[i].from) {
      int to = edge[i].to;
      if (dep[to] == -1 && edge[i].flow) {
        dep[to] = dep[now] + 1;
        q.push(to);
      }
    }
  }
  return dep[T] != -1;
}
int dfs(int now, int lim) {
  if (now == T) return lim;
  int sum = 0;
  for (int i = last[now]; i; i = edge[i].from) {
    int to = edge[i].to;
    if (dep[to] == dep[now] + 1 && edge[i].flow) {
      int tmp = dfs(to, min(lim - sum, edge[i].flow));
      if (tmp) {
        edge[i].flow -= tmp;
        edge[i ^ 1].flow += tmp;
        sum += tmp;
        if (sum == lim) return sum;
      }
    }
  }
  if (sum == 0) dep[now] = -1;
  return sum;
}
void Dinic() {
  max_flow = 0;
  while (bfs()) {
    max_flow += dfs(S, inf);
  }
}
void Dfs(int now) {
  if (v1[now]) return;
  v1[now] = 1;
  for (int i = last[now]; i; i = edge[i].from) {
    if (!v2[edge[i].to - n]) v2[edge[i].to - n] = 1, Dfs(link[edge[i].to]);
  }
}
int main() {
  int x, y;
  n = read();
  for (int i = (1); i <= (n); ++i) {
    scanf("%s", A);
    insert(A, i);
    B[i] = A;
  }
  getfail();
  for (int i = (1); i <= (n); ++i) find(i);
  for (int k = (1); k <= (n); ++k)
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n); ++j) dis[i][j] |= dis[i][k] & dis[k][j];
  for (int i = (1); i <= (n); ++i) dis[i][i] = 0;
  S = 2 * n + 1, T = S + 1;
  for (int i = (1); i <= (n); ++i) {
    add(S, i, 1);
    add(i, S, 0);
    add(i + n, T, 1);
    add(T, i + n, 0);
    for (int j = (1); j <= (n); ++j) {
      if (dis[i][j]) {
        add(i, j + n, 1);
        add(j + n, i, 0);
      }
    }
  }
  Dinic();
  ans = n - max_flow;
  int nn;
  print(ans);
  putchar('\n');
  ;
  for (int i = (2); i <= (cnt); ++i) {
    if (edge[i].come <= n && edge[i].to <= 2 * n && edge[i].flow == 0)
      link[edge[i].to] = edge[i].come;
  }
  for (int i = last[S]; i; i = edge[i].from) {
    if (edge[i].flow) Dfs(edge[i].to);
  }
  for (int i = (1); i <= (n); ++i)
    if (v1[i] && !v2[i]) print(i), putchar(' ');
  return 0;
}