#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
int h[maxn][maxn], temp[maxn][maxn];
long long g[maxn * maxn];
int main() {
  int n, m, a, b;
  int g0, x, y, z;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  scanf("%d%d%d%d", &g0, &x, &y, &z);
  g[0] = g0;
  for (int i = 1; i <= (n + 1) * (m + 1); ++i)
    g[i] = (g[i - 1] * x % z + 1ll * y) % z;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) h[i][j] = g[(i - 1) * m + j - 1];
  }
  for (int j = 1; j <= m; ++j) {
    deque<int> q;
    for (int i = 1; i <= n; ++i) {
      if (q.size() && i - a + 1 > q.front()) q.pop_front();
      while (q.size() && h[q.back()][j] >= h[i][j]) q.pop_back();
      q.push_back(i);
      if (i >= a) temp[i][j] = h[q.front()][j];
    }
  }
  long long ans = 0;
  for (int i = a; i <= n; ++i) {
    deque<int> q;
    for (int j = 1; j <= m; ++j) {
      if (q.size() && j - b + 1 > q.front()) q.pop_front();
      while (q.size() && temp[i][q.back()] >= temp[i][j]) q.pop_back();
      q.push_back(j);
      if (j >= b) {
        ans += (long long)temp[i][q.front()];
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
