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;
int N;
vector<int> G[1513];
bool used[1513];
int match[1513];
int E[1513][1513];
const int kind = 2;
struct Node {
  int fail;
  int nxt[kind];
  int cnt;
  int sub;
  Node() {
    fail = 0;
    cnt = 0;
    sub = 0;
    memset(nxt, 0, sizeof(nxt));
  }
};
int q[1000013 * 10];
char str[1000013 * 10 + 1513];
char* strs[1513];
Node node[1000013 * 10];
int nds = 1;
void inst(char* str, int root, int id) {
  int p = root;
  int i = 0, index;
  while (str[i]) {
    index = str[i] - 'a';
    if (node[p].nxt[index] == 0) {
      node[p].nxt[index] = ++nds;
    }
    p = node[p].nxt[index];
    i++;
  }
  node[p].cnt = id;
}
void build_ac_automation(int root) {
  int i;
  int head = 0, tail = 0;
  node[root].fail = 0;
  q[tail++] = root;
  while (head != tail) {
    int temp = q[head++];
    int p = 0;
    for (i = 0; i < kind; i++) {
      if (node[temp].nxt[i] != 0) {
        if (temp == root) {
          node[node[temp].nxt[i]].fail = root;
        } else {
          p = node[temp].fail;
          while (p != 0) {
            if (node[p].nxt[i] != 0) {
              node[node[temp].nxt[i]].fail = node[p].nxt[i];
              break;
            }
            p = node[p].fail;
          }
          if (p == 0) {
            node[node[temp].nxt[i]].fail = root;
          }
        }
        q[tail++] = node[temp].nxt[i];
      }
    }
    node[temp].sub = node[node[temp].fail].sub;
    if (node[temp].cnt) {
      node[temp].sub = node[temp].cnt;
    }
  }
}
bool dfs(int v) {
  used[v] = true;
  for (int i = int(0), __border_righti = int(G[v].size()); i < __border_righti;
       i++) {
    int u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}
void check(int v) {
  if (used[v]) {
    return;
  }
  used[v] = true;
  for (int i = int(0), __border_righti = int(G[v].size()); i < __border_righti;
       i++) {
    int u = G[v][i], w = match[u];
    if (!used[u]) {
      used[u] = true;
      check(w);
    }
  }
}
int main() {
  scanf("%d", &N);
  nds = 0;
  int r = ++nds;
  int n = 0;
  for (int i = int(0), __border_righti = int(N); i < __border_righti; i++) {
    scanf("%s", str + n);
    strs[i] = str + n;
    n += strlen(str + n) + 1;
    inst(strs[i], r, i + 1);
  }
  build_ac_automation(r);
  memset(E, 0, sizeof(E));
  for (int i = int(0), __border_righti = int(N); i < __border_righti; i++) {
    int r = 1;
    for (int j = 0; strs[i][j]; j++) {
      r = node[r].nxt[strs[i][j] - 'a'];
      E[i][node[r].sub] = true;
    }
    r = node[r].fail;
    E[i][node[r].sub] = true;
    for (int j = int(0), __border_rightj = int(N); j < __border_rightj; j++) {
      E[i][j] = E[i][j + 1];
    }
  }
  for (int k = int(0), __border_rightk = int(N); k < __border_rightk; k++) {
    for (int i = int(0), __border_righti = int(N); i < __border_righti; i++) {
      for (int j = int(0), __border_rightj = int(N); j < __border_rightj; j++) {
        E[i][j] = E[i][j] || E[i][k] && E[k][j];
      }
    }
  }
  for (int i = int(0), __border_righti = int(N); i < __border_righti; i++) {
    for (int j = int(0), __border_rightj = int(N); j < __border_rightj; j++) {
      if (i != j && E[i][j]) {
        G[i].push_back(j + N);
      }
    }
  }
  int res = N;
  memset(match, -1, sizeof(match));
  std::vector<int> ans;
  for (int v = int(0), __border_rightv = int(N); v < __border_rightv; v++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) {
        res--;
      } else {
        ans.push_back(v);
      }
    }
  }
  memset(used, 0, sizeof(used));
  printf("%d\n", res);
  for (int i = int(0), __border_righti = int(res); i < __border_righti; i++) {
    check(ans[i]);
  }
  for (int i = int(0), __border_righti = int(N); i < __border_righti; i++) {
    if (used[i] && !used[i + N]) {
      printf("%d ", i + 1);
    }
  }
  return 0;
}