#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000;
int g[maxn * maxn + 5], c[maxn + 5][maxn + 5];
int c1[maxn + 5][maxn + 5], c2[maxn + 5][maxn + 5];
int n, m, a, b;
int x, y, z;
int s[maxn + 5];
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  scanf("%d%d%d%d", &g[0], &x, &y, &z);
  for (int i = 1; i < n * m; i++) g[i] = (1LL * g[i - 1] * x + y) % z;
  for (int i = 0; i < n * m; i++) c[i / m + 1][i % m + 1] = g[i];
  int h, t;
  for (int i = 1; i <= n; i++) {
    h = 0, t = 0;
    for (int j = 1; j <= b; j++) {
      while (h < t && c[i][s[t - 1]] >= c[i][j]) t--;
      s[t++] = j;
    }
    c1[i][1] = c[i][s[h]];
    for (int j = b + 1; j <= m; j++) {
      while (h < t && s[h] <= j - b) h++;
      while (h < t && c[i][s[t - 1]] >= c[i][j]) t--;
      s[t++] = j;
      c1[i][j - b + 1] = c[i][s[h]];
    }
  }
  long long ans = 0;
  for (int j = 1; j <= m - b + 1; j++) {
    h = 0;
    t = 0;
    for (int i = 1; i <= a; i++) {
      while (h < t && c1[s[t - 1]][j] >= c1[i][j]) t--;
      s[t++] = i;
    }
    ans += c1[s[h]][j];
    for (int i = a + 1; i <= n; i++) {
      while (h < t && s[h] <= i - a) h++;
      while (h < t && c1[s[t - 1]][j] >= c1[i][j]) t--;
      s[t++] = i;
      ans += c1[s[h]][j];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
