#include <bits/stdc++.h>
using namespace std;
long long mat[3001][3001], a1[3001][3001];
int main() {
  long long n, m, a, b, i, j, ans = 0;
  cin >> n >> m >> a >> b;
  long long g1, x, y, z;
  cin >> g1 >> x >> y >> z;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      mat[i][j] = g1;
      g1 = (g1 * x + y) % z;
    }
  }
  for (i = 1; i <= n; i++) {
    deque<long long> q;
    for (j = 1; j <= b - 1; j++) {
      while (!q.empty() && q.back() > mat[i][j]) q.pop_back();
      q.push_back(mat[i][j]);
    }
    for (j = b; j <= m; j++) {
      while (!q.empty() && q.back() > mat[i][j]) q.pop_back();
      q.push_back(mat[i][j]);
      a1[i][j] = q.front();
      if (!q.empty() && q.front() == mat[i][j - b + 1]) q.pop_front();
    }
  }
  for (j = b; j <= m; j++) {
    deque<long long> q;
    for (i = 1; i <= a - 1; i++) {
      while (!q.empty() && q.back() > a1[i][j]) q.pop_back();
      q.push_back(a1[i][j]);
    }
    for (i = a; i <= n; i++) {
      while (!q.empty() && q.back() > a1[i][j]) q.pop_back();
      q.push_back(a1[i][j]);
      mat[i][j] = q.front();
      if (!q.empty() && q.front() == a1[i - a + 1][j]) q.pop_front();
    }
  }
  for (i = a; i <= n; i++) {
    for (j = b; j <= m; j++) {
      ans = (ans + mat[i][j]);
    }
  }
  cout << ans << endl;
}
