#include <bits/stdc++.h>
using namespace std;
int const maxn = 3005;
int n, m, A, B, x, y, z, g[maxn * maxn], a[maxn][maxn], s1[maxn][maxn],
    s2[maxn][maxn];
int q[maxn];
signed main() {
  cin >> n >> m >> A >> B;
  cin >> g[0] >> x >> y >> z;
  for (int i = 1; i <= n * m; i++) g[i] = ((long long)g[i - 1] * x % z + y) % z;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) a[i][j] = g[(i - 1) * m + j - 1];
  for (int i = 1; i <= n; i++) {
    int l = 1, r = 0;
    q[++r] = 1;
    for (int j = 1; j <= m; j++) {
      while (l <= r && q[l] < j - B + 1) l++;
      while (l <= r && a[i][q[r]] >= a[i][j]) r--;
      q[++r] = j;
      if (j >= B) s1[i][j] = a[i][q[l]];
    }
  }
  for (int j = 1; j <= m; j++) {
    int l = 1, r = 0;
    q[++r] = 1;
    for (int i = 1; i <= n; i++) {
      while (l <= r && q[l] < i - A + 1) l++;
      while (l <= r && s1[q[r]][j] >= s1[i][j]) r--;
      q[++r] = i;
      if (i >= A) s2[i][j] = s1[q[l]][j];
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) ans += (long long)s2[i][j];
  printf("%I64d\n", ans);
  return 0;
}
