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>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
inline long long power(long long a, long long b) {
  long long multiply = 1;
  for (int i = (0); i < (b); i++) {
    multiply *= a;
  }
  return multiply;
}
const int N = 751;
int n;
string in[N], p;
int node[10000005][2];
int root, nnode, link[10000005], termlink[10000005], terminal[10000005];
bool graph[N][N];
void init() {
  root = 0;
  nnode = 0;
}
void insertword(int idx) {
  p = in[idx];
  int len = p.size();
  int now = root;
  for (int i = (0); i < (len); i++) {
    int x = p[i] - 'a';
    if (!node[now][x]) {
      node[now][x] = ++nnode;
    }
    now = node[now][x];
  }
  terminal[now] = idx;
}
void push_links() {
  queue<int> q;
  link[0] = -1;
  q.push(0);
  memset(termlink, -1, sizeof(termlink));
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 2; i++) {
      if (!node[u][i]) continue;
      int v = node[u][i];
      int j = link[u];
      while (j != -1 && !node[j][i]) j = link[j];
      if (j != -1)
        link[v] = node[j][i];
      else
        link[v] = 0;
      if (terminal[link[v]] != -1)
        termlink[v] = link[v];
      else
        termlink[v] = termlink[link[v]];
      q.push(v);
    }
  }
}
void buildgraph() {
  for (int i = (0); i < (n); i++) {
    int curr = root;
    for (int j = (0); j < (in[i].size()); j++) {
      char ch = in[i][j];
      curr = node[curr][(int)ch - 'a'];
      int st = curr;
      if (terminal[st] == -1) st = termlink[st];
      for (int k = st; k >= 0; k = termlink[k]) {
        if (terminal[k] == i) continue;
        if (graph[i][terminal[k]]) break;
        graph[i][terminal[k]] = true;
      }
    }
  }
}
void transclose() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) graph[i][j] |= (graph[i][k] & graph[k][j]);
    }
  }
}
vector<int> bp[N];
int matched[N], revmatch[N];
bool seen[N], visited[2][N], cover[N];
bool trymatch(int u) {
  for (int j = (0); j < (bp[u].size()); j++) {
    int v = bp[u][j];
    if (seen[v]) continue;
    seen[v] = true;
    if (matched[v] < 0 || trymatch(matched[v])) {
      matched[v] = u;
      revmatch[u] = v;
      return true;
    }
  }
  return false;
}
int maxbpm(int sz) {
  memset(matched, -1, sizeof(matched));
  memset(revmatch, -1, sizeof(revmatch));
  int ret = 0;
  for (int i = (0); i < (sz); i++) {
    memset(seen, false, sizeof(seen));
    if (trymatch(i)) ret++;
  }
  return ret;
}
void dfsLast(int u, bool side) {
  if (visited[side][u]) return;
  visited[side][u] = true;
  if (!side) {
    for (int i = 0; i < n; i++) {
      if (graph[u][i] && matched[u] != i) dfsLast(i, 1 - side);
    }
  } else
    dfsLast(matched[u], 1 - side);
}
void buildbp() {
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (n); j++) {
      if (graph[i][j]) {
        bp[i].push_back(j);
      }
    }
  }
}
void solveRest() {
  buildbp();
  int out = maxbpm(n);
  for (int i = (0); i < (n); i++) {
    if (revmatch[i] == -1) {
      dfsLast(i, 0);
    }
  }
  vector<int> ans;
  for (int i = (0); i < (n); i++) {
    if (!(!visited[0][i] || visited[1][i])) ans.push_back(i + 1);
  }
  cout << n - out << "\n";
  for (int J = (0); J < (ans.size()); J++) cout << ans[J] << " ";
  cout << "\n";
}
void Test() {
  n = 10;
  graph[4][8] = graph[4][9] = graph[7][0] = 1;
  graph[7][1] = graph[7][2] = graph[7][3] = 1;
  solveRest();
}
int main() {
  int test, cases = 1;
  cin >> n;
  memset(terminal, -1, sizeof(terminal));
  for (int i = (0); i < (n); i++) {
    cin >> in[i];
    insertword(i);
  }
  push_links();
  buildgraph();
  transclose();
  solveRest();
  return 0;
}