func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long double pi = acos(-1);   const int MOD = 1e9 + 7;   const long long int LINF = 0x3f3f3f3f3f3f3f3f;   int n, m, k, s;   const int MAXN = 2005;   int a[MAXN][MAXN];   int maxma[15], maxme[15], minma[15], minme[15];   int seq[MAXN * MAXN];   int get(int v1, int v2) {     int ret = 0;     ret = max(ret, maxma[v1] - minma[v2]);     ret = max(ret, maxme[v1] - minme[v2]);     return ret;   }   int main() {     memset(minma, INF, sizeof(minma));     memset(minme, INF, sizeof(minme));     scanf( %d%d%d , &n, &m, &k);     scanf( %d , &s);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %d , &a[i][j]);         int v = a[i][j];         int ma = i + j;         int me = i - j;         maxma[v] = max(maxma[v], ma);         maxme[v] = max(maxme[v], me);         minma[v] = min(minma[v], ma);         minme[v] = min(minme[v], me);       }     }     int resp = 0;     scanf( %d , &seq[0]);     for (int i = 1; i < s; i++) {       scanf( %d , &seq[i]);       resp = max(resp, max(get(seq[i], seq[i - 1]), get(seq[i - 1], seq[i])));     }     printf( %d n , resp);     return 0;   }   