#include <bits/stdc++.h>
using namespace std;
long long g;
deque<int> dq;
long long h[3005][3005];
long long arr[3005][3005];
int main() {
  int n, m, a, b;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  long long x, y, z;
  cin >> g >> x >> y >> z;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      h[i][j] = g;
      g = (g * x + y);
      g %= z;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i < a; i++) {
      while (dq.size() && h[dq.back()][j] >= h[i][j]) dq.pop_back();
      dq.push_back(i);
    }
    for (int ii = 1, i = a; i <= n; ii++, i++) {
      while (dq.size() && h[dq.back()][j] >= h[i][j]) dq.pop_back();
      dq.push_back(i);
      while (dq.front() < ii) dq.pop_front();
      arr[ii][j] = h[dq[0]][j];
    }
    dq.clear();
  }
  long long ans = 0;
  for (int i = 1; i + a - 1 <= n; i++) {
    for (int j = 1; j < b; j++) {
      while (dq.size() && arr[i][dq.back()] >= arr[i][j]) dq.pop_back();
      dq.push_back(j);
    }
    for (int jj = 1, j = b; j <= m; jj++, j++) {
      while (dq.size() && arr[i][dq.back()] >= arr[i][j]) dq.pop_back();
      dq.push_back(j);
      while (dq.front() < jj) dq.pop_front();
      long long pp = arr[i][dq[0]];
      ans += pp;
    }
    dq.clear();
  }
  printf("%lld\n", ans);
}
