#include <bits/stdc++.h>
using namespace std;
long long field[3030][3030];
long long mi[3030][3030];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, A, B;
  cin >> N >> M >> A >> B;
  long long g, x, y, z;
  cin >> g >> x >> y >> z;
  long long val = g;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      field[i][j] = val;
      val = (val * x + y) % z;
    }
  }
  for (int i = 0; i < N; i++) {
    deque<long long> DQ;
    for (int j = 0; j < B; j++) {
      if (DQ.empty())
        DQ.push_back(j);
      else {
        while (!DQ.empty() && field[i][DQ.back()] >= field[i][j]) DQ.pop_back();
        DQ.push_back(j);
      }
    }
    for (int j = 0; j + B - 1 < M; j++) {
      mi[i][j] = field[i][DQ.front()];
      if (DQ.front() == j) DQ.pop_front();
      if (j + B < M) {
        while (!DQ.empty() && field[i][DQ.back()] >= field[i][j + B])
          DQ.pop_back();
        DQ.push_back(j + B);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i + B - 1 < M; i++) {
    deque<long long> DQ;
    for (int j = 0; j < A; j++) {
      if (DQ.empty())
        DQ.push_back(j);
      else {
        while (!DQ.empty() && mi[DQ.back()][i] >= mi[j][i]) DQ.pop_back();
        DQ.push_back(j);
      }
    }
    for (int j = 0; j + A - 1 < N; j++) {
      ans += mi[DQ.front()][i];
      if (DQ.front() == j) DQ.pop_front();
      if (j + A < N) {
        while (!DQ.empty() && mi[DQ.back()][i] >= mi[j + A][i]) DQ.pop_back();
        DQ.push_back(j + A);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
