func_code_string: #include <bits/stdc++.h>   using namespace std;   int ag[9][2], cg[9][2];   int main() {     int n, m, k, s, t, t2, ans = 0;     scanf( %d %d %d %d , &n, &m, &k, &s);     memset(cg, 0x3f3f3f3f, sizeof(cg));     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         scanf( %d , &t);         ag[t - 1][0] = max(ag[t - 1][0], i + 1 + j + 1);         cg[t - 1][0] = min(cg[t - 1][0], i + 1 + j + 1);         ag[t - 1][1] = max(ag[t - 1][1], i - j);         cg[t - 1][1] = min(cg[t - 1][1], i - j);       }     scanf( %d , &t);     for (int i = 1; i < s; i++) {       scanf( %d , &t2);       ans = max(ans, ag[t - 1][0] - cg[t2 - 1][0]);       ans = max(ans, ag[t2 - 1][0] - cg[t - 1][0]);       ans = max(ans, ag[t - 1][1] - cg[t2 - 1][1]);       ans = max(ans, ag[t2 - 1][1] - cg[t - 1][1]);       t = t2;     }     printf( %d n , ans);     return 0;   }   