#include <bits/stdc++.h>
using namespace std;
void printvector(std::vector<long long> v) {
  for (long long i = 0; i < v.size(); ++i) {
    cout << v[i] << " ";
  }
  cout << "" << endl;
}
void printarray(long long a[], long long n) {
  for (long long i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << "" << endl;
}
class segment_tree {
 public:
  long long n;
  std::vector<long long> a, tree;
  segment_tree(std::vector<long long> d) {
    a = d;
    n = a.size();
    while (n & (n - 1) != 0) {
      a.push_back(0);
      n = a.size();
    }
    long long k = 2 * n;
    while (k--) tree.push_back(0);
    build();
  }
  void build() {
    for (long long i = 0; i < n; i++) tree[i + n] = a[i];
    for (long long i = n - 1; i > 0; i--)
      tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
  }
  void update(long long h, long long val) {
    h += n;
    tree[h] = val;
    for (; h > 1; h >>= 1) tree[h >> 1] = min(tree[h], tree[h ^ 1]);
  }
  long long query(long long l, long long r) {
    long long ans = INT_MAX;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) ans = min(ans, tree[l++]);
      if (r & 1) ans = min(ans, tree[--r]);
    }
    return ans;
  }
};
void solve() {
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  long long g, x, y, z;
  cin >> g >> x >> y >> z;
  long long fill[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      fill[i][j] = g;
      g = ((g * x) % z + y) % z;
    }
  }
  long long vm[n - a + 1][m];
  for (long long j = 0; j < m; j++) {
    std::vector<long long> d;
    for (long long i = 0; i < n; i++) d.push_back(fill[i][j]);
    segment_tree s(d);
    for (long long i = 0; i < n - a + 1; i++) {
      vm[i][j] = s.query(i, i + a);
    }
  }
  long long ans[n - a + 1][m - b + 1];
  for (long long i = 0; i < n - a + 1; i++) {
    std::vector<long long> d;
    for (long long j = 0; j < m; j++) d.push_back(vm[i][j]);
    segment_tree s(d);
    for (long long j = 0; j < m - b + 1; j++) {
      ans[i][j] = s.query(j, j + b);
    }
  }
  long long fi = 0;
  for (long long i = 0; i < n - a + 1; i++) {
    for (long long j = 0; j < m - b + 1; j++) {
      fi += ans[i][j];
    }
  }
  cout << fi << endl;
}
int32_t main() {
  solve();
  return 0;
}
