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;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
}
const int MAXC = 2;
struct Node {
  Node* child[MAXC];
  Node* link;
  Node* prev_patt;
  int pch;
  Node* par;
  int ends;
  int node_num;
};
const int MAX = 1e7 + 5;
int foo = -1;
const int MAXN = 755;
int n;
vector<Node*> pathnodes[MAXN];
Node* new_node() {
  Node* ptr = new Node();
  for (int i = 0; i < MAXC; i++) {
    ptr->child[i] = NULL;
  }
  ptr->link = ptr->par = NULL;
  ptr->pch = ptr->ends = 0;
  ptr->node_num = ++foo;
  ptr->prev_patt = NULL;
  return ptr;
}
Node* root;
void add_string(string& s, int idx) {
  Node* cur = root;
  for (auto c : s) {
    Node*& v = cur->child[c - 'a'];
    if (v == NULL) {
      v = new_node();
      v->par = cur;
      v->pch = c - 'a';
    }
    cur = v;
    pathnodes[idx].push_back(cur);
  }
  cur->prev_patt = cur;
  cur->ends = idx;
}
int G[MAXN][MAXN];
queue<Node*> q;
void bfs() {
  root->link = root;
  for (int i = 0; i < MAXC; i++) {
    Node*& v = root->child[i];
    if (v != NULL) {
      v->link = root;
      q.push(v);
      if (v->prev_patt == NULL) {
        v->prev_patt = root;
      }
    }
  }
  root->prev_patt = root;
  while (!q.empty()) {
    Node* u = q.front();
    q.pop();
    for (int ch = 0; ch < MAXC; ch++) {
      Node*& v = u->child[ch];
      if (v != NULL) {
        Node* cur = u->link;
        while (cur != root && cur->child[ch] == NULL) cur = cur->link;
        if (cur != root) {
          v->link = cur->child[ch];
        } else if (cur->child[ch] == NULL) {
          v->link = root;
        } else {
          v->link = cur->child[ch];
        }
        q.push(v);
        if (v->prev_patt == NULL) {
          v->prev_patt = v->link->prev_patt;
        }
      }
    }
  }
}
string s;
class HopcraftKarp {
 public:
  bool reverse;
  int n, m;
  int dis[2 * MAXN];
  int match[2 * MAXN];
  vector<int> adj[2 * MAXN];
  HopcraftKarp(int a, int b) {
    n = a;
    m = b;
    reverse = false;
    if (n > m) {
      reverse = true;
      swap(n, m);
    }
    for (int i = 0; i <= n; ++i) {
      match[i] = 0;
    }
  }
  void reset(int a, int b) {
    n = a;
    m = b;
    reverse = false;
    if (n > m) {
      reverse = true;
      swap(n, m);
    }
    for (int i = 0; i <= n; ++i) {
      match[i] = 0;
    }
    for (int i = 0; i <= (2 * n); i++) {
      dis[i] = 0;
      match[i] = 0;
      adj[i].clear();
    }
  }
  void add_edge(int a, int b) {
    if (reverse) {
      adj[a + n].push_back(b);
      adj[b].push_back(a + n);
    } else {
      adj[a].push_back(b + n);
      adj[b + n].push_back(a);
    }
  }
  bool bfs() {
    queue<int> q;
    for (int i = 1; i <= n; ++i) {
      if (match[i] == 0) {
        dis[i] = 0;
        q.push(i);
      } else {
        dis[i] = INT_MAX;
      }
    }
    dis[0] = INT_MAX;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (u != 0) {
        for (size_t i = 0; i < adj[u].size(); ++i) {
          int v = adj[u][i];
          if (dis[match[v]] == INT_MAX) {
            dis[match[v]] = dis[u] + 1;
            q.push(match[v]);
          }
        }
      }
    }
    return dis[0] != INT_MAX;
  }
  int dfs(int u) {
    if (u != 0) {
      for (size_t i = 0; i < adj[u].size(); ++i) {
        int v = adj[u][i];
        if (dis[match[v]] == dis[u] + 1) {
          if (dfs(match[v])) {
            match[v] = u;
            match[u] = v;
            return true;
          }
        }
      }
      dis[u] = INT_MAX;
      return false;
    }
    return true;
  }
  int max_matching() {
    int matching = 0;
    while (bfs()) {
      for (int i = 1; i <= n; ++i) {
        if (match[i] == 0 && dfs(i)) {
          ++matching;
        }
      }
    }
    return matching;
  }
  void print_matches() {
    for (int i = 1; i <= n; ++i) {
      if (match[i] != 0) {
        printf("%d matches with %d\n", i, match[i] - n);
      }
    }
  }
};
HopcraftKarp bpm(0, 0);
vector<int> g[2 * MAXN];
bool mark[2 * MAXN];
bool inVc[2 * MAXN];
void dfs_vc(int u) {
  mark[u] = 1;
  for (auto v : g[u]) {
    if (!mark[v]) {
      dfs_vc(v);
    }
  }
}
int main(int argc, char* argv[]) {
  io();
  root = new_node();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    add_string(s, i);
  }
  bfs();
  Node* prev_str = NULL;
  for (int i = 1; i <= n; i++) {
    for (auto node : pathnodes[i]) {
      prev_str = node->prev_patt;
      if (prev_str->ends == i) {
        prev_str = node->link->prev_patt;
      }
      if (prev_str != root) {
        assert(prev_str->ends != 0);
        G[i][prev_str->ends] = 1;
      }
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        G[i][j] |= (G[i][k] && G[k][j]);
      }
    }
  }
  bpm.reset(n, n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (G[i][j]) {
        bpm.add_edge(i, j);
      }
    }
  }
  int max_len_antichain = (n - bpm.max_matching());
  cout << max_len_antichain << '\n';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (G[i][j]) {
        if (bpm.match[i] == j + n) {
          g[j + n].push_back(i);
        } else {
          g[i].push_back(j + n);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (bpm.match[i] == 0) {
      dfs_vc(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (bpm.match[i] != 0) {
      if (!mark[i]) {
        inVc[i] = 1;
      }
      if (mark[bpm.match[i]]) {
        inVc[bpm.match[i]] = 1;
      }
    }
  }
  int cntr = 0;
  for (int i = 1; i <= n; i++) {
    if (inVc[i] || inVc[i + n]) continue;
    cout << i << " ";
    cntr++;
  }
  assert(cntr == (max_len_antichain));
  return 0;
}