func_code_string: #include <bits/stdc++.h>   using namespace std;   long long ans, n, m, a, r, c, sum, sums[1000002], sumsR[1000002],       sumsC[1000002], sumsR2[1000002], sumsC2[1000002];   const long long p = 998244353;   struct el {     long long x, r, c;   };   bool operator<(el x, el y) { return x.x < y.x; }   el arr[1000002];   long long modu(long long am, long long bm) {     long long ansm = am, p2 = p - 2, h = bm;     while (p2 > 0) {       if ((p2 & 1) != 0) ansm = (ansm * h) % p;       h = (h * h) % p;       p2 /= 2;     }     return ansm;   }   int main() {     cin >> n >> m;     for (long long i = 1; i <= n * m; i++) {       cin >> a;       arr[i].x = a;       arr[i].r = (i - 1) / m + 1;       arr[i].c = (i - 1) % m + 1;     }     cin >> r >> c;     sort(arr + 1, arr + n * m + 1);     sums[1] = 0;     sumsR[1] = arr[1].r % p;     sumsC[1] = arr[1].c % p;     sumsR2[1] = (arr[1].r * arr[1].r) % p;     sumsC2[1] = (arr[1].c * arr[1].c) % p;     a = 0;     for (int i = 2; i <= n * m; i++) {       if (arr[i].x != arr[i - 1].x) a = i - 1;       sum = 0;       sum += sums[a] % p;       sum %= p;       sum += (a * arr[i].r * arr[i].r) % p;       sum %= p;       sum += (a * arr[i].c * arr[i].c) % p;       sum %= p;       sum += (sumsR2[a]) % p;       sum %= p;       sum += (sumsC2[a]) % p;       sum %= p;       sum -= (2 * arr[i].r * sumsR[a]) % p;       sum %= p;       if (sum < 0) sum += p;       sum -= (2 * arr[i].c * sumsC[a]) % p;       sum %= p;       if (sum < 0) sum += p;       sum = modu(sum, a);       if (arr[i].r == r && arr[i].c == c) {         ans = sum;         break;       }       sumsR[i] = (sumsR[i - 1] + arr[i].r) % p;       sumsC[i] = (sumsC[i - 1] + arr[i].c) % p;       sumsR2[i] = (sumsR2[i - 1] + arr[i].r * arr[i].r) % p;       sumsC2[i] = (sumsC2[i - 1] + arr[i].c * arr[i].c) % p;       sums[i] = (sums[i - 1] + sum);     }     cout << ans << endl;     return 0;   }   