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 GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long mod = 998244353;
const int inf = 1e9;
bool vis[1700];
int in[760];
bool adj[760][760];
bool trans[760][760];
bool rep[760];
int tot = 0;
int fin(int i) {
  if (in[i] != i) {
    in[i] = fin(in[i]);
  }
  return in[i];
}
struct edkarp {
  vector<vector<int>> cap;
  vector<vector<int>> eds;
  int n, m;
  void init(int _n) {
    n = _n;
    m = (n - 2) / 2;
    cap.assign(n, vector<int>(n, 0));
    eds.assign(n, vector<int>(0));
  }
  void add(int u, int v, int c) {
    eds[u].emplace_back(v);
    eds[v].emplace_back(u);
    cap[u][v] = c;
  }
  int bfs(int st, int tar, vector<int>& p) {
    fill(p.begin(), p.end(), -1);
    p[st] = -2;
    queue<pair<int, int>> q;
    q.push(make_pair(st, inf));
    while (!q.empty()) {
      int i = q.front().first, flow = q.front().second;
      q.pop();
      for (auto& x : eds[i]) {
        if (p[x] == -1 && cap[i][x]) {
          p[x] = i;
          int nf = min(flow, cap[i][x]);
          if (x == tar) {
            return nf;
          }
          q.push(make_pair(x, nf));
        }
      }
    }
    return 0;
  }
  int maxflow(int st, int tar) {
    vector<int> p(n);
    int flow = 0;
    int nf;
    while (nf = bfs(st, tar, p)) {
      flow += nf;
      int cr = tar;
      while (cr != st) {
        cap[p[cr]][cr] -= nf;
        cap[cr][p[cr]] += nf;
        cr = p[cr];
      }
    }
    return flow;
  }
  void dfs(int i) {
    ;
    vis[i] = 1;
    for (auto& x : eds[i])
      if (!vis[x] && x != 0 && x != n - 1) {
        if (cap[i][x]) dfs(x);
      }
  }
  void sten() {
    fill(vis, vis + n, false);
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= m; j++) {
        if (cap[j + m][i]) {
          in[i] = 1;
          break;
        }
      }
    }
    for (int i = 1; i <= m; i++) {
      if (in[i] == 0 && !vis[i]) dfs(i);
    }
  }
};
const int K = 2;
struct node {
  node* ch[K];
  node* p;
  node* nt;
  node* sl;
  int ind = -1;
  bool pch;
  node(node* p = NULL, bool b = false) : p(p), pch(b) {
    sl = NULL;
    ch[0] = NULL;
    ch[1] = NULL;
    nt = NULL;
  }
};
template <class node>
struct ahoc {
  node* root = NULL;
  edkarp fl;
  ahoc() { root = new node(); }
  void init(int n) { fl.init(n); }
  inline int getin(char c) { return c - 'a'; }
  void ins(string const& s, int i) {
    node* cr = root;
    for (char c : s) {
      int z = getin(c);
      if (!cr->ch[z]) {
        cr->ch[z] = new node(cr, c == 'b');
      }
      cr = cr->ch[z];
    }
    if (cr->ind == -1)
      cr->ind = i;
    else
      rep[i] = 1, tot++;
  }
  void trav(string const& s, int i) {
    node* cr = root;
    for (char c : s) {
      if (cr->ind != -1) {
        adj[cr->ind][i] = trans[cr->ind][i] = true;
      }
      int z = getin(c);
      cr = cr->ch[z];
      node* tmp = get_nt(cr);
      if (tmp != root) adj[tmp->ind][i] = trans[tmp->ind][i] = true;
    }
  }
  node* get_sl(node* cr) {
    if (!cr->sl) {
      if (cr == root || cr->p == root)
        cr->sl = root;
      else
        cr->sl = go(get_sl(cr->p), cr->pch);
    }
    return cr->sl;
  }
  node* go(node* cr, bool c) {
    int z = c;
    if (!cr->ch[z]) {
      if (cr == root)
        cr->ch[z] = root;
      else
        cr->ch[z] = go(get_sl(cr), c);
    }
    return cr->ch[z];
  }
  node* get_nt(node* cr) {
    if (!cr->nt) {
      node* tmp = get_sl(cr);
      if (tmp == root) {
        cr->nt = root;
      } else if (tmp->ind == -1) {
        cr->nt = get_nt(tmp);
      } else {
        cr->nt = tmp;
      }
    }
    return cr->nt;
  }
};
string s[760];
int n;
ahoc<node> fo;
void dfs(int i) {
  vis[i] = 1;
  for (int j = (int)1; j != (int)n + 1; j = j + 1) {
    if (j == i) continue;
    if (!trans[i][j]) continue;
    if (!vis[j]) dfs(j);
    for (int k = (int)1; k != (int)n + 1; k = k + 1) {
      if (k == i || k == j) continue;
      if (!trans[j][k]) continue;
      trans[i][k] = 1;
    }
  }
}
void solve() {
  cin >> n;
  for (int i = (int)1; i != (int)n + 1; i = i + 1) {
    cin >> s[i];
  }
  for (int i = (int)1; i != (int)n + 1; i = i + 1) {
    fo.ins(s[i], i);
  }
  fo.init(2 * n + 2);
  for (int i = (int)1; i != (int)n + 1; i = i + 1) {
    fo.trav(s[i], i);
    fo.fl.add(0, i, 1);
    fo.fl.add(n + i, 2 * n + 1, 1);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
  }
  for (int i = (int)1; i != (int)n + 1; i = i + 1) {
    for (int j = (int)1; j != (int)n + 1; j = j + 1) {
      if (i == j) continue;
      if (trans[i][j]) {
        fo.fl.add(i, j + n, 1);
      }
    }
  }
  cout << n - tot - fo.fl.maxflow(0, 2 * n + 1) << '\n';
  fo.fl.sten();
  for (int i = 1; i <= n; i++) {
    if (vis[i] && !vis[i + n] && !rep[i]) cout << i << " ";
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}