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 MAXK = 1600;
const int MAXN = (int)1e7 + 10;
int n, cap[MAXK][MAXK], dist[MAXK], term[MAXN], link[MAXN], w[MAXN],
    to[MAXN][2];
char str[MAXN];
bool u[MAXK][MAXK], mt[MAXK][MAXK], f[2][MAXK], seen[MAXK];
string v[MAXK];
vector<int> que;
vector<int> gr[MAXK];
void add(int x, int y, int c) {
  cap[x][y] = c;
  cap[y][x] = 0;
  gr[x].push_back(y);
  gr[y].push_back(x);
}
void add_str(string &s, int j, int &l) {
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    int c = s[i] - 'a';
    if (to[cur][c] == 0) {
      to[cur][c] = l++;
    }
    cur = to[cur][c];
  }
  w[cur] = j;
  term[cur] = cur;
}
void calc_str(string &s, int j) {
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    int c = s[i] - 'a';
    cur = to[cur][c];
    for (int p = term[cur]; p != 0; p = term[link[p]]) {
      if (u[j][w[p]]) {
        break;
      }
      u[j][w[p]] = true;
    }
  }
}
void push_links() {
  que.push_back(0);
  for (int i = 0; i < que.size(); i++) {
    int p = que[i];
    int l = link[p];
    if (term[p] == 0) {
      term[p] = term[l];
    }
    for (int c = 0; c < 2; c++) {
      if (to[p][c] != 0) {
        link[to[p][c]] = ((p != 0) ? to[l][c] : 0);
        que.push_back(to[p][c]);
      } else {
        to[p][c] = to[l][c];
      }
    }
  }
  que.clear();
}
bool bfs(int start, int target) {
  for (int i = 0; i <= target; i++) {
    dist[i] = -1;
    seen[i] = false;
  }
  dist[start] = 0;
  que.push_back(start);
  for (int i = 0; i < que.size(); i++) {
    int cur = que[i];
    for (int j = 0; j < gr[cur].size(); j++) {
      int nxt = gr[cur][j];
      if (dist[nxt] == -1 && cap[cur][nxt] > 0) {
        dist[nxt] = dist[cur] + 1;
        que.push_back(nxt);
      }
    }
  }
  que.clear();
  return dist[target] != -1;
}
int aug(int start, int target, int flow) {
  if (start == target) {
    return flow;
  }
  if (seen[start]) {
    return 0;
  }
  seen[start] = true;
  int ret = 0;
  for (int i = 0; i < gr[start].size(); i++) {
    int nxt = gr[start][i];
    if (dist[nxt] == dist[start] + 1 && cap[start][nxt] > 0) {
      int val = aug(nxt, target, min(flow, cap[start][nxt]));
      if (val != 0) {
        ret += val;
        flow -= val;
        cap[start][nxt] -= val;
        cap[nxt][start] += val;
      }
      if (flow == 0) {
        return ret;
      }
    }
  }
  return ret;
}
void dfs(int s, int i) {
  if (f[s][i]) {
    return;
  }
  f[s][i] = true;
  for (int j = 0; j < n; j++) {
    if (s == 0 && u[i][j]) {
      dfs(1, j);
    } else if (s == 1 && u[j][i] && mt[j][i]) {
      dfs(0, j);
    }
  }
}
int main() {
  int l = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    v[i] = str;
    add_str(v[i], i, l);
  }
  push_links();
  for (int i = 0; i < n; i++) {
    calc_str(v[i], i);
  }
  for (int i = 0; i < n; i++) {
    u[i][i] = false;
  }
  for (int i = 1; i <= n; i++) {
    add(0, i, 1);
    add(n + i, 2 * n + 1, 1);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (u[i][j]) {
        add(i + 1, n + j + 1, 1);
      }
    }
  }
  int tot = 0;
  for (int i = 0; bfs(0, 2 * n + 1); i++) {
    tot += aug(0, 2 * n + 1, 1000000);
  }
  printf("%d\n", n - tot);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (u[i][j] && cap[i + 1][n + j + 1] == 0) {
        mt[i][j] = true;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if (mt[i][j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      dfs(0, i);
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (f[0][i] && !f[1][i]) {
      ans.push_back(i + 1);
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
  }
  puts("");
  return 0;
}