#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
const int inf = 0x3f3f3f3f;
int g[maxn * maxn];
int n, m, a, b;
long long x, y, z;
struct xx {
  int x, id;
  xx(int x = 0, int id = 0) : x(x), id(id) {}
};
deque<xx> de[maxn], AnsDe;
void Push(deque<xx> &tmp, int val, int index) {
  if (tmp.empty() || tmp.back().x <= val)
    tmp.push_back(xx(val, index));
  else {
    while (!tmp.empty() && tmp.back().x > val) tmp.pop_back();
    tmp.push_back(xx(val, index));
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  scanf("%d%lld%lld%lld", &g[0], &x, &y, &z);
  long long tmp;
  for (int i = 1; i <= (n + 10) * (m + 10); ++i) {
    tmp = (((long long)g[i - 1] * x % z) + y) % z;
    g[i] = tmp;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < b; ++j) {
      Push(de[i], g[(i - 1) * m + j - 1], j);
    }
  }
  long long ans = 0;
  for (int j = b; j <= m; ++j) {
    while (!AnsDe.empty()) AnsDe.pop_front();
    for (int i = 1; i <= n; ++i) {
      Push(de[i], g[(i - 1) * m + j - 1], j);
      while (de[i].front().id <= j - b) de[i].pop_front();
      Push(AnsDe, de[i].front().x, i);
      while (AnsDe.front().id <= i - a) AnsDe.pop_front();
      if (i >= a) ans += AnsDe.front().x;
    }
  }
  cout << ans << endl;
  return 0;
}
