#include <bits/stdc++.h>
using namespace std;
using minStack = stack<pair<long long, long long> >;
struct minQueue {
  minStack in, out;
  minQueue() {
    in.push({(long long)1e16, (long long)1e16});
    out.push({(long long)1e16, (long long)1e16});
  }
  void push(long long x) {
    long long m = in.top().second;
    in.push({x, min(x, m)});
  }
  long long pop() {
    if (out.top().first == (long long)1e16) {
      while (in.top().first != (long long)1e16) {
        pair<long long, long long> p = in.top();
        in.pop();
        long long m = out.top().second;
        out.push({p.first, min(p.first, m)});
      }
    }
    long long x = out.top().first;
    out.pop();
    assert(x != (long long)1e16);
    return x;
  }
  long long getMin() { return min(in.top().second, out.top().second); }
};
int main() {
  ios::sync_with_stdio(false);
  long long m, n, a, b;
  cin >> n >> m >> a >> b;
  long long g, x, y, z;
  cin >> g >> x >> y >> z;
  vector<vector<long long> > M(n, vector<long long>(m));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      M[i][j] = g;
      g = (g * x + y) % z;
    }
  vector<vector<long long> > min_1d(n, vector<long long>(m - b + 1));
  for (long long i = 0; i < n; i++) {
    minQueue mq;
    for (long long j = 0; j < b; j++) mq.push(M[i][j]);
    for (long long j = b; j < m; j++) {
      min_1d[i][j - b] = mq.getMin();
      mq.pop();
      mq.push(M[i][j]);
    }
    min_1d[i][m - b] = mq.getMin();
  }
  long long ans = 0;
  for (long long j = 0; j <= m - b; j++) {
    minQueue mq;
    for (long long i = 0; i < a; i++) mq.push(min_1d[i][j]);
    for (long long i = a; i < n; i++) {
      ans += mq.getMin();
      mq.pop();
      mq.push(min_1d[i][j]);
    }
    ans += mq.getMin();
  }
  cout << ans << '\n';
  return 0;
}
