#include <bits/stdc++.h>
using namespace std;
long long g[9000000], h[3000][3000], dp[3000][3000];
int main() {
  long long i, j, k;
  long long n, m, a, b;
  long long x, y, z;
  long long res = (long long)0;
  scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
  scanf("%lld %lld %lld %lld", &g[0], &x, &y, &z);
  for (i = 1; i < n * m; i++) g[i] = ((x * g[i - 1]) % z + y) % z;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) h[i][j] = g[m * i + j];
  }
  for (i = 0; i < n; i++) {
    deque<pair<long long, long long>> temp;
    temp.push_back(make_pair(h[i][0], 0));
    for (j = 1; j < b; j++) {
      while (!temp.empty() && temp.back().first >= h[i][j]) temp.pop_back();
      temp.push_back(make_pair(h[i][j], j));
    }
    dp[i][0] = temp.front().first;
    for (j = 1; j + b <= m; j++) {
      while (!temp.empty() && temp.back().first >= h[i][j + b - 1])
        temp.pop_back();
      temp.push_back(make_pair(h[i][j + b - 1], j + b - 1));
      while (!temp.empty() && temp.front().second < j) temp.pop_front();
      dp[i][j] = temp.front().first;
    }
  }
  memset(h, 0, sizeof h);
  for (j = 0; (j + b) <= m; j++) {
    deque<pair<long long, long long>> temp;
    temp.push_back(make_pair(dp[0][j], 0));
    for (i = 1; i < a; i++) {
      while (!temp.empty() && temp.back().first >= dp[i][j]) temp.pop_back();
      temp.push_back(make_pair(dp[i][j], i));
    }
    h[0][j] = temp.front().first;
    for (i = 1; i + a <= n; i++) {
      while (!temp.empty() && temp.back().first >= dp[i + a - 1][j])
        temp.pop_back();
      temp.push_back(make_pair(dp[i + a - 1][j], i + a - 1));
      while (!temp.empty() && temp.front().second < i) temp.pop_front();
      h[i][j] = temp.front().first;
    }
  }
  for (i = 0; i + a <= n; i++) {
    for (j = 0; j + b <= m; j++) res += h[i][j];
  }
  printf("%lld", res);
}
