#include <bits/stdc++.h>
using namespace std;
long long gd[10000020];
long long n, m, w, b;
long long g, x, y, z;
long long a[3001][3001];
deque<pair<long long, long long> > mi;
void make(int k) {
  mi.clear();
  for (int i = 0; i < n; i++) {
    mi.clear();
    for (int j = 0; j < m; j++) {
      while ((!mi.empty()) && mi.front().second + k <= j) mi.pop_front();
      while (!mi.empty()) {
        pair<long long, long long> ba = mi.back();
        if (ba.first >= a[i][j])
          mi.pop_back();
        else
          break;
      }
      mi.push_back({a[i][j], j});
      if (j - k + 1 >= 0) a[i][j - k + 1] = mi.front().first;
    }
  }
}
void ms(int k) {
  mi.clear();
  for (int j = 0; j < m; j++) {
    mi.clear();
    for (int i = 0; i < n; i++) {
      while ((!mi.empty()) && mi.front().second + k <= i) mi.pop_front();
      while (!mi.empty()) {
        pair<long long, long long> ba = mi.back();
        if (ba.first >= a[i][j])
          mi.pop_back();
        else
          break;
      }
      mi.push_back({a[i][j], i});
      if (i - k + 1 >= 0) a[i - k + 1][j] = mi.front().first;
    }
  }
}
void qu() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long t = i * (m);
      t += j;
      a[i][j] = gd[t];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> w >> b;
  cin >> g >> x >> y >> z;
  gd[0] = g;
  for (int i = 1; i <= 1e7; i++) {
    gd[i] = gd[i - 1] * x + y;
    if (gd[i] >= z) gd[i] %= z;
  }
  qu();
  make(b);
  ms(w);
  long long sum = 0;
  for (int i = 0; i <= n - w; i++) {
    for (int j = 0; j <= m - b; j++) {
      sum += a[i][j];
    }
  }
  cout << sum;
  return 0;
}
