#include <bits/stdc++.h>
using namespace std;
long long mn[3005][3005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  long long g0, x, y, z;
  cin >> g0 >> x >> y >> z;
  long long val[n + 4][m + 4], g[n * m + 4];
  memset(val, 0, sizeof val);
  memset(g, 0, sizeof g);
  g[0] = g0;
  for (long long i = 1; i <= 2 * n * m; i++) {
    g[i] = (g[i - 1] * x + y) % z;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      val[i][j] = g[(i - 1) * m + j - 1];
    }
  }
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      mn[i][j] = 2 * 1000000000;
    }
  }
  for (long long j = 1; j <= m; j++) {
    deque<long long> dq;
    for (long long i = 1; i <= a; i++) {
      while (dq.size() && val[dq.back()][j] >= val[i][j]) dq.pop_back();
      dq.push_back(i);
    }
    mn[1][j] = val[dq.front()][j];
    for (long long i = 2; i <= (n - a + 1); i++) {
      while (dq.size() && dq.front() < i) dq.pop_front();
      while (dq.size() && val[dq.back()][j] >= val[i + a - 1][j]) dq.pop_back();
      dq.push_back(i + a - 1);
      mn[i][j] = val[dq.front()][j];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= (n - a + 1); i++) {
    deque<long long> dq;
    for (long long j = 1; j <= b; j++) {
      while (dq.size() && mn[i][dq.back()] >= mn[i][j]) dq.pop_back();
      dq.push_back(j);
    }
    ans += mn[i][dq.front()];
    for (long long j = 2; j <= (m - b + 1); j++) {
      while (dq.size() && dq.front() < j) dq.pop_front();
      while (dq.size() && mn[i][dq.back()] >= mn[i][j + b - 1]) dq.pop_back();
      dq.push_back(j + b - 1);
      ans += mn[i][dq.front()];
    }
  }
  cout << ans << endl;
  return 0;
}
