#include <bits/stdc++.h>
using namespace std;
struct SegmentTree {
  static constexpr int MAXN = 3333;
  vector<int> t = vector<int>(2 * MAXN, 1000010000);
  void init(vector<int> &a) {
    copy((a).begin(), (a).end(), t.begin() + MAXN);
    for (int i = MAXN - 1; i > 0; --i) {
      t[i] = min(t[2 * i], t[2 * i + 1]);
    }
  }
  int query(int l, int r) {
    int res = 1000010000;
    for (l += MAXN, r += MAXN + 1; l < r; l /= 2, r /= 2) {
      if (l % 2) {
        res = min(t[l], res);
        ++l;
      }
      if (r % 2) {
        --r;
        res = min(t[r], res);
      }
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vector<vector<int> > v(n, vector<int>(m));
  long long g0, x, y, z;
  cin >> g0 >> x >> y >> z;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      g0 %= z;
      v[i][j] = g0;
      g0 = (g0 * x % z + y) % z;
    }
  }
  vector<SegmentTree> cols(m);
  for (int j = 0; j < m; ++j) {
    static vector<int> tmp;
    tmp.reserve(n);
    tmp.clear();
    for (int i = 0; i < n; ++i) {
      tmp.push_back(v[i][j]);
    }
    cols[j].init(tmp);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i + a - 1 >= n) break;
    deque<int> dq;
    int k = 0;
    for (int j = 0; j < m; ++j) {
      if (j + b - 1 >= m) break;
      while (!dq.empty() && dq[0] < j) dq.pop_front();
      while (k - j < b && k < m) {
        while (!dq.empty() && cols[dq.back()].query(i, i + a - 1) >=
                                  cols[k].query(i, i + a - 1)) {
          dq.pop_back();
        }
        dq.push_back(k);
        ++k;
      }
      ans += cols[dq[0]].query(i, i + a - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}
