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 MAXN = 750 + 10;
const int MAXM = 1e07 + 10;
const int MAXL = 2 * MAXN + MAXN * MAXN;
const int INF = 0x7fffffff;
struct LFDS {
  int to, next;
};
LFDS iLink[MAXN * MAXN];
int iHead[MAXM] = {0}, isize = 0;
void Insert(int u, int v) {
  iLink[++isize].to = v;
  iLink[isize].next = iHead[u];
  iHead[u] = isize;
}
int N;
char str[MAXM];
vector<int> sve[MAXN];
int tr[MAXM][2] = {0}, m = 0;
void insert(int ind) {
  int p = 0, n = strlen(str + 1);
  for (int i = 1; i <= n; i++) {
    int c = str[i] - 'a';
    sve[ind].push_back(c);
    if (!tr[p][c]) tr[p][c] = ++m;
    p = tr[p][c];
  }
  Insert(p, ind);
}
int fail[MAXM] = {0};
queue<int> que;
int lastp[MAXM] = {0};
bitset<MAXN> g[MAXN];
void build() {
  for (int i = 0; i < 2; i++)
    if (tr[0][i]) que.push(tr[0][i]);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    lastp[u] = iHead[fail[u]] ? fail[u] : lastp[fail[u]];
    for (int i = 0; i < 2; i++) {
      if (tr[u][i]) {
        fail[tr[u][i]] = tr[fail[u]][i];
        que.push(tr[u][i]);
      } else
        tr[u][i] = tr[fail[u]][i];
    }
  }
}
void work(int ind) {
  int p = 0;
  for (int i = 0; i < (int)sve[ind].size(); i++) {
    int c = sve[ind][i];
    p = tr[p][c];
    int tp = p;
    for (int j = 1; j <= 2; j++) {
      for (int k = iHead[tp]; k; k = iLink[k].next) {
        int v = iLink[k].to;
        if (v == ind) continue;
        g[v][ind] = 1;
      }
      tp = lastp[tp];
    }
  }
}
struct LFS {
  int to, cap, next;
};
LFS Link[MAXL << 1];
int Head[MAXN << 1] = {0}, size = 1;
void Insert(int u, int v, int cap) {
  Link[++size].to = v;
  Link[size].cap = cap;
  Link[size].next = Head[u];
  Head[u] = size;
}
void add(int x, int y, int cap) {
  Insert(x, y, cap);
  Insert(y, x, 0);
}
int S, T, _N;
int depth[MAXN << 1] = {0};
bool BFS() {
  while (!que.empty()) que.pop();
  memset(depth, 0, sizeof(depth));
  depth[S] = 1, que.push(S);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = Head[u]; i; i = Link[i].next) {
      int v = Link[i].to, cap = Link[i].cap;
      if (depth[v] || !cap) continue;
      depth[v] = depth[u] + 1;
      if (v == T) return true;
      que.push(v);
    }
  }
  return false;
}
int cur[MAXN << 1] = {0};
int Dinic(int p, int flow) {
  if (p == T) return flow;
  int rest = flow;
  for (int &i = cur[p]; i && rest; i = Link[i].next) {
    int v = Link[i].to, cap = Link[i].cap;
    if (depth[v] != depth[p] + 1 || !cap) continue;
    int k = Dinic(v, min(cap, rest));
    if (!k) depth[v] = -1;
    Link[i].cap -= k, Link[i ^ 1].cap += k;
    rest -= k;
  }
  return flow - rest;
}
int MAXFLOW() {
  int ret = 0;
  while (BFS()) {
    for (int i = 1; i <= _N; i++) cur[i] = Head[i];
    ret += Dinic(S, INF);
  }
  return ret;
}
int match[MAXN] = {0};
bool tagl[MAXN] = {false}, tagr[MAXN] = {false};
void DFS(int u) {
  tagr[u - N] = true;
  for (int i = 1; i <= N; i++)
    if (g[i][u - N] && !tagl[i]) {
      tagl[i] = true;
      DFS(match[i]);
    }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s", str + 1);
    insert(i);
  }
  build();
  for (int i = 1; i <= N; i++) work(i);
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      if (g[i][k]) g[i] |= g[k];
  S = 2 * N + 1, _N = T = 2 * N + 2;
  for (int i = 1; i <= N; i++) add(S, i, 1), add(i + N, T, 1);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (g[i][j]) add(i, j + N, 1);
  int ans = N - MAXFLOW();
  printf("%d\n", ans);
  for (int i = 1; i <= N; i++)
    if (!Link[4 * i - 2].cap)
      for (int j = Head[i]; j; j = Link[j].next)
        if (!Link[j].cap) {
          match[i] = Link[j].to;
          break;
        }
  for (int i = 1; i <= N; i++)
    if (Link[4 * i].cap) DFS(i + N);
  for (int i = 1; i <= N; i++)
    if (!tagl[i] && tagr[i]) printf("%d ", i);
  puts("");
  return 0;
}