#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int INF = (int)1e9;
struct MinStack {
  stack<pii> a, b;
  MinStack() {}
  void push(int x) {
    int mn = (b.empty() ? x : min(b.top().second, x));
    b.push(pii(x, mn));
  }
  void pop() {
    if (a.empty()) {
      while (!b.empty()) {
        int x = b.top().first;
        b.pop();
        int mn = (a.empty() ? x : min(x, a.top().second));
        a.push(pii(x, mn));
      }
    }
    a.pop();
  }
  int get() {
    int res = INF;
    if (!a.empty()) res = min(res, a.top().second);
    if (!b.empty()) res = min(res, b.top().second);
    return res;
  }
};
int n, m, a, b;
vector<vector<int>> h, mn;
void gen(int g0, int x, int y, int z) {
  h.resize(n, vector<int>(m));
  vector<int> g(n * m);
  g[0] = g0;
  for (int i = 1; i < n * m; i++) g[i] = (1ll * g[i - 1] * x + y) % z;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) h[i][j] = g[i * m + j];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> a >> b;
  int g0, x, y, z;
  cin >> g0 >> x >> y >> z;
  gen(g0, x, y, z);
  mn.resize(n, vector<int>(m));
  for (int j = 0; j < m; j++) {
    MinStack deq;
    for (int i = 0; i < a; i++) deq.push(h[i][j]);
    for (int i = 0; i + a <= n; i++) {
      mn[i][j] = deq.get();
      if (i + a == n) continue;
      deq.pop();
      deq.push(h[i + a][j]);
    }
  }
  long long ans = 0;
  for (int i = 0; i + a <= n; i++) {
    MinStack deq;
    for (int j = 0; j < b; j++) deq.push(mn[i][j]);
    for (int j = 0; j + b <= m; j++) {
      ans += deq.get();
      if (j + b == m) continue;
      deq.pop();
      deq.push(mn[i][j + b]);
    }
  }
  cout << ans;
  return 0;
}
