func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3002;   int n, m, a, b;   long long G[N][N], x, y, z, g[N * N], r[N][N], ans;   deque<int> q;   void init() {     for (int i = 1; i <= (n - 1) * m + m - 1; i++) {       g[i] = (g[i - 1] * x % z + y) % z;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         G[i][j] = g[(i - 1) * m + j - 1];       }     }   }   void cal1() {     for (int i = 1; i <= n; i++) {       while (!q.empty()) q.pop_back();       for (int j = 1; j <= m + 1; j++) {         if (j >= b + 1) {           while (!q.empty() && q.front() < j - b) q.pop_front();           r[i][j - b] = G[i][q.front()];         }         while (!q.empty() && G[i][q.back()] > G[i][j]) q.pop_back();         q.push_back(j);       }     }   }   void cal2() {     for (int j = 1; j <= m; j++) {       while (!q.empty()) q.pop_back();       for (int i = 1; i <= n + 1; i++) {         if (i >= a + 1) {           while (!q.empty() && q.front() < i - a) q.pop_front();           ans += r[q.front()][j];         }         while (!q.empty() && r[q.back()][j] > r[i][j]) q.pop_back();         q.push_back(i);       }     }   }   int main() {     scanf( %d %d %d %d %lld %lld %lld %lld , &n, &m, &a, &b, &g[0], &x, &y, &z);     init();     cal1();     cal2();     printf( %lld n , ans);     return 0;   }   