func_code_string: #include <bits/stdc++.h>   int a[2005][2005], b[100005], c[8][10];   int max(int a, int b) { return a > b ? a : b; }   int min(int a, int b) { return a < b ? a : b; }   int main() {     int n, m, k, s;     while (scanf( %d%d%d%d , &n, &m, &k, &s) != EOF) {       for (int i = 1; i <= 9; i++) {         c[0][i] = -1 << 15;         c[1][i] = 1 << 15;         c[2][i] = -1 << 15;         c[3][i] = 1 << 15;         c[4][i] = -1 << 15;         c[5][i] = 1 << 15;         c[6][i] = -1 << 15;         c[7][i] = 1 << 15;       }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           scanf( %d , &a[i][j]);           c[0][a[i][j]] = max(c[0][a[i][j]], i + j);           c[1][a[i][j]] = min(c[1][a[i][j]], i + j);           c[2][a[i][j]] = max(c[2][a[i][j]], i - j);           c[3][a[i][j]] = min(c[3][a[i][j]], i - j);         }       }       for (int i = 0; i < s; i++) {         scanf( %d , &b[i]);       }       int Max = n + m - 2;       int ans = 0;       for (int i = 0; i < s - 1; i++) {         ans = max(ans, c[0][b[i]] - c[1][b[i + 1]]);         ans = max(ans, -c[1][b[i]] + c[0][b[i + 1]]);         ans = max(ans, c[2][b[i]] - c[3][b[i + 1]]);         ans = max(ans, -c[3][b[i]] + c[2][b[i + 1]]);         if (ans >= Max) {           break;         }       }       printf( %d n , ans);     }   }   