#include <bits/stdc++.h>
using namespace std;
long long g[10000005];
long long h[3005][3005];
int main() {
  int n, m, a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  long long x, y, z;
  scanf("%lld%lld%lld%lld", &g[0], &x, &y, &z);
  for (int i = 1; i < n * m + 5; i++) g[i] = (g[i - 1] * x + y) % z;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      h[i][j] = g[(i)*m + j];
    }
  }
  for (int i = 0; i < n; i++) {
    vector<long long> minn;
    for (int j = 0; j < b; j++) {
      while (minn.size() > 0 && h[i][j] < h[i][minn.back()]) minn.pop_back();
      minn.push_back(j);
    }
    h[i][0] = h[i][minn[0]];
    for (int j = 1; j <= m - b; j++) {
      if (minn[0] < j) minn.erase(minn.begin(), minn.begin() + 1);
      while (minn.size() > 0 && h[i][j + b - 1] < h[i][minn.back()])
        minn.pop_back();
      minn.push_back(j + b - 1);
      h[i][j] = h[i][minn[0]];
    }
  }
  for (int i = 0; i < m; i++) {
    vector<long long> minn;
    for (int j = 0; j < a; j++) {
      while (minn.size() > 0 && h[j][i] < h[minn.back()][i]) minn.pop_back();
      minn.push_back(j);
    }
    h[0][i] = h[minn[0]][i];
    for (int j = 1; j <= n - a; j++) {
      if (minn[0] < j) minn.erase(minn.begin(), minn.begin() + 1);
      while (minn.size() > 0 && h[j + a - 1][i] < h[minn.back()][i])
        minn.pop_back();
      minn.push_back(j + a - 1);
      h[j][i] = h[minn[0]][i];
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) ans += h[i][j];
  printf("%lld", ans);
}
