func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   long long n, k, t, m, q, flag = 0;   long long po(long long k, long long n, long long ans, long long temp,                long long ans1) {     if (n == 0) return ans;     while (temp <= n) {       ans *= ans1;       ans %= mod;       ans1 = ans1 * ans1;       ans1 %= mod;       n = n - temp;       temp *= 2;     }     return po(k, n, ans, 1, k) % mod;   }   long long min(long long a, long long b) {     if (a > b)       return b;     else       return a;   }   long long max(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long md[100 + 1][100 + 1];   vector<long long> v[100 + 1];   long long bfs(long long i, long long j, queue<long long> q, long long z,                 map<long long, long long> m1) {     long long o = q.size();     if (o == 0) return -1;     for (int l = 0; l < o; l++) {       long long b = q.front();       if (b == j)         return z;       else {         if (m1[b] != 1)           for (int i = 0; i < v[b].size(); i++) {             q.push(v[b][i]);           }         m1[b] = 1;         q.pop();       }     }     return bfs(i, j, q, z + 1, m1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     t = 1;     while (t--) {       cin >> n;       char c[n][n];       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) cin >> c[i][j];       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (c[i][j] ==  1 ) v[i + 1].push_back(j + 1);         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           queue<long long> q;           map<long long, long long> m1;           q.push(i + 1);           md[i + 1][j + 1] = bfs(i + 1, j + 1, q, 0, m1);         }       }       long long m;       cin >> m;       long long a[m];       for (int i = 0; i < m; i++) cin >> a[i];       vector<long long> ans;       long long pi = a[0], pii = 0;       ans.push_back(a[0]);       for (int i = 1; i < m; i++) {         if (md[pi][a[i]] == i - pii)           ;         else {           ans.push_back(a[i - 1]);           pi = a[i - 1];           pii = i - 1;         }       }       cout << ans.size() + 1;       cout <<   n ;       for (int i = 0; i < ans.size(); i++) {         cout << ans[i] <<    ;       }       cout << a[m - 1];     }     return 0;   }   