#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 5;
long long ans;
long long mp[N][N], g[N * N], x, n, m, z, y, a, b, g0;
long long hang[N][N];
deque<pair<long long, long long> > q;
void h(long long *s, long long *ans) {
  while (!q.empty()) q.pop_back();
  for (int i = (1); i <= (b); i++) {
    while (!q.empty() && q.back().first > s[i]) q.pop_back();
    q.push_back(make_pair(s[i], i));
  }
  ans[1] = q.front().first;
  for (int i = (2); i <= (m - b + 1); i++) {
    if (!q.empty() && q.front().second < i) q.pop_front();
    while (!q.empty() && q.back().first > s[i + b - 1]) q.pop_back();
    q.push_back(make_pair(s[i + b - 1], i + b - 1));
    ans[i] = q.front().first;
  }
}
void v(int x) {
  while (!q.empty()) q.pop_back();
  for (int i = (1); i <= (a); i++) {
    while (!q.empty() && q.back().first > hang[i][x]) q.pop_back();
    q.push_back(make_pair(hang[i][x], i));
  }
  mp[1][x] = q.front().first;
  for (int i = (2); i <= (n - a + 1); i++) {
    if (!q.empty() && q.front().second < i) q.pop_front();
    while (!q.empty() && q.back().first > hang[i + a - 1][x]) q.pop_back();
    q.push_back(make_pair(hang[i + a - 1][x], i + a - 1));
    mp[i][x] = q.front().first;
  }
}
long long sol() {
  scanf("%lld%lld%lld%lld", &n, &m, &a, &b);
  scanf("%lld%lld%lld%lld", &g0, &x, &y, &z);
  g[0] = g0;
  for (int i = (1); i <= (n * m); i++) g[i] = (g[i - 1] * x + y) % z;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (m); j++) mp[i][j] = g[(i - 1) * m + j - 1];
  for (int i = (1); i <= (n); i++) h(mp[i], hang[i]);
  for (int i = (1); i <= (m); i++) v(i);
  long long ans = 0;
  for (int i = (1); i <= (n - a + 1); i++)
    for (int j = (1); j <= (m - b + 1); j++) ans += mp[i][j];
  return ans;
}
int main() { printf("%lld", sol()); }
