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 L = 1e7 + 7;
int go[L][2];
int suf[L];
int supsuf[L];
int id[L];
bool vis[L];
int uk = 0;
void add(string s, int idx) {
  int cur = 0;
  for (auto c : s) {
    if (go[cur][c - 'a'] == -1) {
      go[cur][c - 'a'] = ++uk;
    }
    cur = go[cur][c - 'a'];
  }
  id[cur] = idx;
}
void bfs() {
  suf[0] = 0;
  supsuf[0] = -1;
  queue<int> q;
  for (int i = 0; i < 2; ++i) {
    if (go[0][i] == -1) {
      go[0][i] = 0;
    } else {
      suf[go[0][i]] = 0;
      supsuf[go[0][i]] = -1;
      q.push(go[0][i]);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < 2; ++i) {
      if (go[u][i] == -1) {
        go[u][i] = go[suf[u]][i];
      } else {
        int who = go[u][i];
        suf[who] = go[suf[u]][i];
        if (id[suf[who]] != -1) {
          supsuf[who] = suf[who];
        } else {
          supsuf[who] = supsuf[suf[who]];
        }
        q.push(go[u][i]);
      }
    }
  }
}
const int N = 1000;
bool A[N][N];
vector<int> g[N];
int usedL[N];
int usedR[N];
int mtL[N];
int mtR[N];
int timer = 0;
bool kuhn(int u) {
  if (usedL[u] == timer) return false;
  usedL[u] = timer;
  for (auto v : g[u]) {
    if (mtR[v] == -1) {
      mtR[v] = u;
      return true;
    }
  }
  for (auto v : g[u]) {
    if (kuhn(mtR[v])) {
      mtR[v] = u;
      return true;
    }
  }
  return false;
}
void dfs(int u) {
  usedL[u] = 1;
  for (auto v : g[u]) {
    if (v != mtL[u] && !usedR[v]) {
      usedR[v] = 1;
      if (mtR[v] != -1 && !usedL[mtR[v]]) {
        dfs(mtR[v]);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  for (int i = 0; i < L; ++i) {
    for (int j = 0; j < 2; ++j) {
      go[i][j] = -1;
    }
    id[i] = -1;
  }
  map<string, int> last;
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    add(s, i);
    a[i] = s;
  }
  bfs();
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    vector<bool> vis(n);
    for (int j = 0; j < a[i].size(); ++j) {
      int c = a[i][j] - 'a';
      cur = go[cur][c];
      if (id[cur] != -1 && !vis[id[cur]]) {
        A[i][id[cur]] = 1;
        vis[id[cur]] = 1;
      }
      int kek = cur;
      while (supsuf[kek] != -1 && !vis[id[supsuf[kek]]]) {
        kek = supsuf[kek];
        vis[id[kek]] = 1;
        A[i][id[kek]] = 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    A[i][i] = 0;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        A[i][j] |= A[i][k] & A[k][j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (A[i][j]) g[i].push_back(j);
    }
  }
  for (int i = 0; i < N; ++i) {
    mtL[i] = mtR[i] = -1;
  }
  int mem = 0;
  for (int i = 0; i < n; ++i) {
    ++timer;
    if (kuhn(i)) ++mem;
  }
  for (int i = 0; i < n; ++i) {
    if (mtR[i] != -1) {
      mtL[mtR[i]] = i;
    }
  }
  for (int i = 0; i < N; ++i) {
    usedL[i] = usedR[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    if (mtL[i] == -1) {
      dfs(i);
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (!usedL[i] || usedR[i])
      ;
    else {
      ans.push_back(i + 1);
    }
  }
  cout << n - mem << '\n';
  for (auto i : ans) {
    cout << i << ' ';
  }
}