#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
int aa[maxn][maxn], mp[maxn][maxn], q[maxn];
int main() {
  int n, m, a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  long long g, x, y, z;
  scanf("%lld%lld%lld%lld", &g, &x, &y, &z);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      aa[i][j] = g;
      g = (g * x + y) % z;
    }
  }
  for (int i = 1; i <= n; i++) {
    int l = 1, r = 0;
    for (int j = 1; j <= b; j++) {
      while (r && aa[i][q[r]] > aa[i][j]) r--;
      q[++r] = j;
    }
    mp[i][1] = aa[i][q[l]];
    for (int j = 2; j + b - 1 <= m; j++) {
      if (q[l] == j - 1) l++;
      while (l <= r && aa[i][q[r]] > aa[i][j + b - 1]) r--;
      q[++r] = j + b - 1;
      mp[i][j] = aa[i][q[l]];
    }
  }
  long long ans = 0;
  for (int j = 1; j <= m; j++) {
    int l = 1, r = 0;
    for (int i = 1; i <= a; i++) {
      while (r && mp[q[r]][j] > mp[i][j]) r--;
      q[++r] = i;
    }
    (ans += mp[q[l]][j]);
    for (int i = 2; i + a - 1 <= n; i++) {
      if (q[l] == i - 1) l++;
      while (l <= r && mp[q[r]][j] > mp[i + a - 1][j]) r--;
      q[++r] = i + a - 1;
      (ans += mp[q[l]][j]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
