func_code_string: #include <bits/stdc++.h>   long long mpow(long long a, long long n, long long mod) {     long long ret = 1;     long long b = a;     while (n) {       if (n & 1) ret = (ret * b) % mod;       b = (b * b) % mod;       n >>= 1;     }     return (long long)ret;   }   using namespace std;   int main() {     cin.sync_with_stdio(0);     int i, j, n, m, k, s;     cin >> n >> m >> k >> s;     int a[4][10];     for (j = 0; j < 10; j++) a[0][j] = -1e9, a[2][j] = -1e9;     for (j = 0; j < 10; j++) a[1][j] = 1e9, a[3][j] = 1e9;     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) {         long long p;         cin >> p;         a[0][p] = max(a[0][p], i + j);         a[1][p] = min(a[1][p], i + j);         a[2][p] = max(a[2][p], i - j);         a[3][p] = min(a[3][p], i - j);       }     int p;     cin >> p;     int ans = -1;     for (j = 1; j < s; j++) {       int q;       cin >> q;       ans = max(ans, a[0][p] - a[1][q]);       ans = max(ans, a[0][q] - a[1][p]);       ans = max(ans, a[2][p] - a[3][q]);       ans = max(ans, a[2][q] - a[3][p]);       p = q;     }     cout << ans;     return 0;   }   