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;
template <class T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
template <class T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
template <class T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
const int maxn = 1005;
const int maxl = 10000005;
const int maxm = 1000005;
int flag[maxl];
queue<int> q;
struct aho {
  struct node {
    int c[2];
    int fail;
    int last;
    node() { c[0] = c[1] = fail = last = 0; }
  };
  int sz;
  node T[maxl];
  aho() { sz = 1; }
  int insert(string &str, int id);
  void getlink(string &res, int id);
  void build(void);
};
struct graph {
  int n;
  int fst[maxn];
  int v[maxm];
  int nxt[maxm];
  int e_cn;
  bool adj[maxn][maxn];
  int match[maxn << 1];
  bool vis[maxn << 1];
  bool fin[maxn << 1];
  bool tag[maxn << 1];
  graph() {
    memset(fst, 0, sizeof(fst));
    memset(adj, 0, sizeof(adj));
    memset(match, 0, sizeof(match));
    e_cn = 0;
  }
  void addedge(int x, int y) {
    e_cn++, v[e_cn] = y;
    nxt[e_cn] = fst[x], fst[x] = e_cn;
  }
  bool go(int cn) {
    for (int i = fst[cn]; i; i = nxt[i]) {
      if (!vis[v[i]]) {
        vis[v[i]] = true;
        if (!match[v[i]] || go(match[v[i]])) {
          match[v[i]] = cn;
          match[cn] = v[i];
          return true;
        }
      }
    }
    return false;
  }
  void rebuild() {
    for (int i = 1; i <= n; i++) adj[i][i] = false;
    for (int k = 1; k <= n; k++) {
      for (int i = 1; i <= n; i++) {
        if (!adj[i][k]) continue;
        for (int j = 1; j <= n; j++) {
          adj[i][j] |= (adj[i][k] & adj[k][j]);
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i != j && adj[i][j]) {
          addedge(i, j + n);
        }
      }
    }
  }
  int hungary() {
    int res = 0;
    for (int i = 1; i <= n; i++) {
      memset(vis, 0, sizeof(vis));
      res += go(i);
    }
    return res;
  }
  void dfs(int cn, int step) {
    tag[cn] = true;
    if (step == 0) {
      for (int i = fst[cn]; i; i = nxt[i]) {
        if (!tag[v[i]] && v[i] != match[cn]) {
          dfs(v[i], step ^ 1);
        }
      }
    } else {
      if (!tag[match[cn]] && match[cn] > 0) {
        dfs(match[cn], step ^ 1);
      }
    }
  }
  void printplan() {
    vector<int> ans;
    memset(fin, 0, sizeof(fin));
    memset(tag, 0, sizeof(tag));
    for (int i = 1; i <= n; i++) {
      if (!match[i]) {
        dfs(i, 0);
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!tag[i]) {
        fin[i] = true;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (tag[i + n]) {
        fin[i] = true;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!fin[i] && !fin[i + n]) {
        ans.push_back(i);
      }
    }
    printf("%d\n", (int)ans.size());
    for (int i = 0; i < (int)ans.size(); i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  }
};
int n;
aho s;
string str[maxn];
graph g1;
void input() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
    s.insert(str[i], i);
  }
}
int aho::insert(string &str, int id) {
  int cn = 1;
  for (int i = 0; str[i]; i++) {
    if (!T[cn].c[str[i] - 'a']) {
      T[cn].c[str[i] - 'a'] = ++sz;
    }
    cn = T[cn].c[str[i] - 'a'];
  }
  assert(flag[cn] == 0);
  if (!flag[cn]) {
    flag[cn] = id;
  }
  return cn;
}
void aho::getlink(string &str, int id) {
  int cn = 1;
  for (int i = 0; str[i]; i++) {
    cn = T[cn].c[str[i] - 'a'];
    if (flag[cn]) {
      g1.adj[id][flag[cn]] = true;
    }
    if (flag[T[cn].last]) {
      g1.adj[id][flag[T[cn].last]] = true;
    }
  }
}
void aho::build() {
  while (!q.empty()) q.pop();
  for (int i = 0; i < 2; i++) T[0].c[i] = 1;
  q.push(1);
  while (!q.empty()) {
    int cn = q.front();
    q.pop();
    for (int i = 0; i < 2; i++) {
      if (!T[cn].c[i]) {
        T[cn].c[i] = T[T[cn].fail].c[i];
        continue;
      }
      int cur = T[cn].fail;
      while (!T[cur].c[i]) cur = T[cur].fail;
      T[T[cn].c[i]].fail = T[cur].c[i];
      T[T[cn].c[i]].last =
          flag[T[cur].c[i]] ? T[cur].c[i] : T[T[cur].c[i]].last;
      q.push(T[cn].c[i]);
    }
  }
}
void prepare() {
  s.build();
  for (int i = 1; i <= n; i++) s.getlink(str[i], i);
  g1.n = n;
  g1.rebuild();
}
void solve() {
  g1.hungary();
  g1.printplan();
}
int main() {
  input();
  prepare();
  solve();
  return 0;
}