#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long oo = 1e18 + 7;
const int BASE = 10000;
void solve() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vector<vector<int> > h(n + 1, vector<int>(m + 1));
  long long g0, x, y, z;
  cin >> g0 >> x >> y >> z;
  vector<long long> g(1, g0);
  for (int i = 1; i <= n * m; i++) {
    g.push_back((g[i - 1] * x + y) % z);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      h[i][j] = g[(i - 1) * m + j - 1];
    }
  }
  deque<int> dq;
  for (int i = 1; i <= n; i++) {
    dq.clear();
    for (int j = 1; j <= m; j++) {
      while (!dq.empty() && h[i][dq.back()] >= h[i][j]) {
        dq.pop_back();
      }
      dq.push_back(j);
      if (dq.front() + b <= j) {
        dq.pop_front();
      }
      if (j >= b) {
        h[i][j - b + 1] = h[i][dq.front()];
      }
    }
  }
  long long ans = 0;
  for (int j = 1; j <= m - b + 1; j++) {
    dq.clear();
    for (int i = 1; i <= n; i++) {
      while (!dq.empty() && h[dq.back()][j] >= h[i][j]) {
        dq.pop_back();
      }
      dq.push_back(i);
      if (dq.front() + a <= i) {
        dq.pop_front();
      }
      if (i >= a) {
        ans += h[dq.front()][j];
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);
  solve();
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
