func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   namespace A {   int ch[10001000][2], fail[10001000], end[10001000], cnt;   inline int insert(char *s, int id, int *dis) {     int len = strlen(s), rt = 0;     for (int i = 0; i < len; ++i) {       int d = s[i] -  a ;       if (!ch[rt][d]) ch[rt][d] = ++cnt;       rt = ch[rt][d];     }     if (end[rt]) dis[end[rt]] = 1;     end[rt] = id;     return len;   }   void getfail(int dis[1600][1600]) {     queue<int> q;     if (ch[0][0]) q.push(ch[0][0]);     if (ch[0][1]) q.push(ch[0][1]);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int k = 0; k <= 1; ++k) {         if (!ch[u][k])           ch[u][k] = ch[fail[u]][k];         else {           fail[ch[u][k]] = ch[fail[u]][k];           if (end[fail[ch[u][k]]]) {             if (end[ch[u][k]])               dis[end[ch[u][k]]][end[fail[ch[u][k]]]] = 1;             else               end[ch[u][k]] = end[fail[ch[u][k]]];           }           q.push(ch[u][k]);         }       }     }   }   void match(char *s, int len, int *dis) {     int rt = 0;     for (int i = 0; i < len; ++i) {       rt = ch[rt][s[i] -  a ];       if (end[rt]) dis[end[rt]] = 1;     }   }   };  // namespace A   int n, st[1600], dis[1600][1600];   char s[10001000];   namespace D {   int S, T, tot = 1, fir[1600], nxt[1600 * 1600], to[1600 * 1600],             val[1600 * 1600], dep[1600], cur[1600];   queue<int> q;   inline void addE(int u, int v, int w) {     nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v, val[tot] = w;     nxt[++tot] = fir[v], fir[v] = tot, to[tot] = u, val[tot] = 0;   }   inline bool bfs() {     memset(dep, -1, sizeof dep);     memcpy(cur, fir, sizeof fir);     q.push(S), dep[S] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = fir[u], v; i; i = nxt[i]) {         v = to[i];         if ((~dep[v]) || !val[i]) continue;         dep[v] = dep[u] + 1, q.push(v);       }     }     return (~dep[T]);   }   int dfs(int u, int now) {     if (u == T || !now) return now;     int res = 0;     for (int &i = cur[u], v; i; i = nxt[i]) {       v = to[i];       if (dep[v] != dep[u] + 1 || !val[i]) continue;       int tmp = dfs(v, min(now, val[i]));       if (!tmp) continue;       res += tmp, now -= tmp, val[i] -= tmp, val[i ^ 1] += tmp;       if (!now) break;     }     return res;   }   inline int dinic() {     int res = 0, tmp;     while (bfs())       while ((tmp = dfs(S, INF))) res += tmp;     return res;   }   int mat[1600];   bool vis[1600];   void match(int u) {     if (vis[u]) return;     vis[u] = 1;     for (int i = fir[u]; i; i = nxt[i])       if (!vis[to[i]] && to[i] <= 2 * n) vis[to[i]] = 1, match(mat[to[i]]);   }   void write() {     for (int u = 1; u <= n; ++u)       for (int i = fir[u]; i && !mat[u]; i = nxt[i])         if (!val[i] && to[i] <= 2 * n) mat[mat[u] = to[i]] = u;     for (int u = 1; u <= n; ++u)       if (!mat[u]) match(u);     for (int i = 1; i <= n; ++i) {       if (vis[i] && !vis[i + n]) printf( %d%c , i,    n [i == n]);     }   }   }  // namespace D   using D::addE;   using D::dinic;   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       scanf( %s , s + st[i]);       st[i + 1] = A::insert(s + st[i], i, dis[i]) + st[i];     }     A::getfail(dis);     for (int i = 1; i <= n; ++i) A::match(s + st[i], st[i + 1] - st[i], dis[i]);     for (int k = 1; k <= n; ++k)       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= n; ++j)           if (dis[i][k] && dis[k][j]) dis[i][j] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (dis[i][j]) D::S = 2 * n + 1, D::T = D::S + 1;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (dis[i][j] && i != j) addE(i, j + n, 1);     for (int i = 1; i <= n; ++i) addE(D::S, i, 1), addE(i + n, D::T, 1);     int res = dinic();     res = n - res;     cout << res << endl;     D::write();     return 0;   }   