#include <bits/stdc++.h>
using namespace std;
int g[9000100], d[4000][4000], n, m, x, y, z;
int f[4000][4000];
deque<int> que;
void create() {
  for (int i = 1; i < n * m; i++)
    g[i] = ((long long)g[i - 1] * (long long)x + y) % z;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) d[i][j] = g[(i - 1) * m + j - 1];
}
int main() {
  int q, e;
  cin >> n >> m >> q >> e;
  cin >> g[0] >> x >> y >> z;
  create();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      while (!que.empty() && que.front() <= j - e) que.pop_front();
      while (!que.empty() && d[i][que.back()] >= d[i][j]) que.pop_back();
      que.push_back(j);
      if (j >= e) f[i][j] = d[i][que.front()];
    }
    while (!que.empty()) que.pop_back();
  }
  long long ans = 0;
  for (int j = e; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      while (!que.empty() && que.front() <= i - q) que.pop_front();
      while (!que.empty() && f[que.back()][j] > f[i][j]) que.pop_back();
      que.push_back(i);
      if (i >= q) ans += f[que.front()][j];
    }
    while (!que.empty()) que.pop_back();
  }
  cout << ans;
}
