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 MOD = 1000000007;
const int INF = 1000000001;
const long long int LLINF = 1000000000000000001LL;
const int ALPH = 2;
struct node {
  int s[ALPH];
  int flink = -1, dictlink = -1, par;
  char parChar;
  int word = -1;
  node(int par = -1, char parChar = '$') : par(par), parChar(parChar) {
    for (int i = (0); i <= (ALPH - 1); ++i) s[i] = -1;
  }
  int getSon(char c) { return s[c - 'a']; }
  void setSon(char c, int k) { s[c - 'a'] = k; }
};
const int MAXNODES = 10000003;
node T[MAXNODES];
struct Aho {
  int n = 1;
  Aho(vector<string> &V) {
    for (int i = (0); i <= ((int)(V).size() - 1); ++i) add(V[i], i);
    queue<int> Q;
    Q.push(0);
    while (!Q.empty()) {
      int q = Q.front();
      Q.pop();
      for (int i = (0); i <= (ALPH - 1); ++i)
        if (T[q].s[i] != -1) {
          Q.push(T[q].s[i]);
        }
      if (!q) continue;
      int v = T[T[q].par].flink;
      char pChar = T[q].parChar;
      while (v > -1 && T[v].getSon(pChar) == -1) {
        v = T[v].flink;
      }
      T[q].flink = (v > -1 ? T[v].getSon(pChar) : 0);
      v = T[q].flink;
      if (T[v].word == -1) {
        v = T[v].dictlink;
      }
      T[q].dictlink = v;
    }
  }
  void add(string &s, int ind) {
    int it = 0, v = 0, len = (int)(s).size();
    while (it < len && T[v].getSon(s[it]) != -1) {
      v = T[v].getSon(s[it++]);
    }
    while (it < len) {
      T[n++] = node(v, s[it]);
      T[v].setSon(s[it++], n - 1);
      v = n - 1;
    }
    T[v].word = ind;
  }
  void createEdges(string &s, int id, vector<vector<int> > &G) {
    int v = 0;
    for (char c : s) {
      while (v && T[v].getSon(c) == -1) {
        v = T[v].flink;
      }
      v = max(T[v].getSon(c), 0);
      int it = v;
      while (it > 0) {
        if (T[it].word != -1) {
          int w = T[it].word;
          if (G[w][id]) break;
          G[w][id] = 1;
        }
        it = T[it].dictlink;
      }
    }
  }
};
void solve(vector<string> &T, vector<vector<int> > &G) {
  Aho aho(T);
  for (int i = (0); i <= ((int)(T).size() - 1); ++i)
    aho.createEdges(T[i], i, G);
}
int bfs(int s, int t, vector<vector<int> > &G, vector<vector<int> > &Cap,
        vector<vector<int> > &F, vector<int> &par) {
  queue<int> Q;
  Q.push(s);
  vector<int> M((int)(G).size(), INF);
  par[s] = -2;
  while (!Q.empty()) {
    int q = Q.front();
    Q.pop();
    for (int v : G[q]) {
      if (Cap[q][v] > F[q][v] && par[v] == -1) {
        par[v] = q;
        M[v] = min(M[q], Cap[q][v] - F[q][v]);
        Q.push(v);
      }
    }
  }
  return M[t];
}
void dfs(int v, vector<vector<int> > &G, vector<vector<int> > &Cap,
         vector<vector<int> > &F, vector<bool> &vis) {
  vis[v] = 1;
  for (int u : G[v])
    if (!vis[u] && Cap[v][u] > F[v][u]) {
      dfs(u, G, Cap, F, vis);
    }
}
vector<int> getMinCutVertices(int s, int t, vector<vector<int> > &G,
                              vector<vector<int> > &Cap) {
  int n = (int)(G).size();
  vector<vector<int> > F(n);
  for (int i = (0); i <= ((int)(F).size() - 1); ++i) F[i].resize(n, 0);
  vector<int> par(n, -1);
  int f = bfs(s, t, G, Cap, F, par);
  int flow = 0;
  while (par[t] != -1) {
    int v = t;
    flow += f;
    while (v != s) {
      int prev = par[v];
      F[prev][v] += f;
      F[v][prev] -= f;
      v = prev;
    }
    par = vector<int>(n, -1);
    f = bfs(s, t, G, Cap, F, par);
  }
  vector<int> vert;
  vector<bool> vis((int)(G).size(), 0);
  dfs(s, G, Cap, F, vis);
  for (int u : G[s])
    if (!vis[u]) {
      vert.push_back(u);
    }
  for (int u : G[t])
    if (vis[u]) {
      vert.push_back(u);
    }
  return vert;
}
void addEdge(int u, int v, int c, vector<vector<int> > &G,
             vector<vector<int> > &Cap) {
  G[u].push_back(v);
  G[v].push_back(u);
  Cap[u][v] += c;
}
vector<int> findSolution(int n, vector<vector<int> > &G) {
  int m = 2 * n + 2;
  vector<vector<int> > network(m);
  vector<vector<int> > cap(m, vector<int>(m, 0));
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (n - 1); ++j)
      if (i != j && G[i][j]) {
        addEdge(2 * i, 2 * j + 1, 1, network, cap);
      }
  for (int i = (0); i <= (n - 1); ++i) {
    addEdge(2 * n, 2 * i, 1, network, cap);
    addEdge(2 * i + 1, 2 * n + 1, 1, network, cap);
  }
  vector<int> s = getMinCutVertices(2 * n, 2 * n + 1, network, cap);
  vector<bool> touched(n, 0);
  for (int v : s) {
    touched[v / 2] = 1;
  }
  vector<int> ans;
  for (int i = (0); i <= (n - 1); ++i)
    if (!touched[i]) {
      ans.push_back(i);
    }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<string> T(n);
  for (int i = (0); i <= ((int)(T).size() - 1); ++i) cin >> T[i];
  vector<vector<int> > G(n, vector<int>(n, 0));
  solve(T, G);
  vector<int> sol = findSolution(n, G);
  cout << (int)(sol).size() << '\n';
  for (int i : sol) {
    cout << 1 + i << ' ';
  }
  return 0;
}