#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int A[N][N], B[N][N];
deque<int> q;
int main() {
  int n, m, a, b;
  long long g, x, y, z;
  long long ans = 0;
  cin >> n >> m >> a >> b;
  cin >> g >> x >> y >> z;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      A[i][j] = g;
      g = ((g * x) % z + y) % z;
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      while (!q.empty() && A[i][q.back()] >= A[i][j]) q.pop_back();
      q.push_back(j);
      if (q.front() <= j - b) q.pop_front();
      B[i][j] = A[i][q.front()];
    }
    q.clear();
  }
  for (int j = b - 1; j < m; j++) {
    for (int i = 0; i < n; i++) {
      while (!q.empty() && B[q.back()][j] >= B[i][j]) q.pop_back();
      q.push_back(i);
      if (q.front() <= i - a) q.pop_front();
      if (i >= a - 1) ans += 1LL * B[q.front()][j];
    }
    q.clear();
  }
  cout << ans << '\n';
  return 0;
}
