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 = 10000001;
struct node {
  node *go[2];
  node *f, *father;
  int e;
};
vector<node *> nodeid;
void push(node *cur, int idx, string &s) {
  for (int i = 0; i < (int)s.length(); ++i) {
    int v = s[i] - 'a';
    if (!cur->go[v]) {
      cur->go[v] = new node();
      cur->go[v]->father = cur;
    }
    cur = cur->go[v];
  }
  cur->e = idx;
  nodeid.push_back(cur);
}
void build(node *root) {
  queue<node *> q;
  for (int i = 0; i < 2; ++i)
    if (root->go[i]) {
      q.push(root->go[i]);
      root->go[i]->f = root;
    } else
      root->go[i] = root;
  while (!q.empty()) {
    auto cur = q.front();
    q.pop();
    if (!cur->e) cur->e = cur->f->e;
    for (int i = 0; i < 2; ++i) {
      if (cur->go[i]) {
        cur->go[i]->f = cur->f->go[i];
        q.push(cur->go[i]);
      } else
        cur->go[i] = cur->f->go[i];
    }
  }
}
template <typename T>
struct dinic {
  struct edge {
    int src, dst;
    T cap, flow;
    int rev;
  };
  int n;
  vector<vector<edge>> adj;
  dinic(int n) : n(n), adj(n) {}
  void add_edge(int src, int dst, T cap) {
    adj[src].push_back({src, dst, cap, 0, (int)adj[dst].size()});
    if (src == dst) adj[src].back().rev++;
    adj[dst].push_back({dst, src, 0, 0, (int)adj[src].size() - 1});
  }
  vector<int> level, iter;
  T augment(int u, int t, T cur) {
    if (u == t) return cur;
    for (int &i = iter[u]; i < (int)adj[u].size(); ++i) {
      edge &e = adj[u][i];
      if (e.cap - e.flow > 0 && level[u] > level[e.dst]) {
        T f = augment(e.dst, t, min(cur, e.cap - e.flow));
        if (f > 0) {
          e.flow += f;
          adj[e.dst][e.rev].flow -= f;
          return f;
        }
      }
    }
    return 0;
  }
  int bfs(int s, int t) {
    level.assign(n, n);
    level[t] = 0;
    queue<int> Q;
    for (Q.push(t); !Q.empty(); Q.pop()) {
      int u = Q.front();
      if (u == s) break;
      for (edge &e : adj[u]) {
        edge &erev = adj[e.dst][e.rev];
        if (erev.cap - erev.flow > 0 && level[e.dst] > level[u] + 1) {
          Q.push(e.dst);
          level[e.dst] = level[u] + 1;
        }
      }
    }
    return level[s];
  }
  T max_flow(int s, int t) {
    for (int u = 0; u < n; ++u)
      for (auto &e : adj[u]) e.flow = 0;
    T flow = 0;
    while (bfs(s, t) < n) {
      iter.assign(n, 0);
      for (T f; (f = augment(s, t, numeric_limits<T>::max())) > 0;) flow += f;
    }
    return flow;
  }
};
const int oo = 0x3f3f3f3f;
const int N = 751;
bool mat[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  node *root = new node();
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    push(root, i, s);
  }
  build(root);
  for (int i = 1; i <= n; ++i) {
    node *cur = nodeid[i - 1];
    mat[cur->f->e][i] = true;
    while (cur != root) {
      mat[cur->e][i] = true;
      cur = cur->father;
    }
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) mat[i][j] |= mat[i][k] & mat[k][j];
  dinic<int> flow(2 * n + 2);
  for (int i = 0; i < n; ++i) {
    flow.add_edge(0, i + 2, 1);
    flow.add_edge(i + 2 + n, 1, 1);
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (mat[i + 1][j + 1]) {
        flow.add_edge(i + 2, j + n + 2, oo);
      }
    }
  }
  int f = flow.max_flow(0, 1);
  vector<int> ans;
  for (int i = 0; i < n; ++i)
    if (flow.level[i + 2] == flow.n && flow.level[i + 2 + n] != flow.n)
      ans.push_back(i + 1);
  cout << ans.size() << endl;
  for (auto v : ans) cout << v << " ";
  cout << endl;
  return 0;
}