#include <bits/stdc++.h>
using std::min;
const int MAXN = 3005, INF = 1e9;
int n, m, a, b;
int _g, _x, _y, _z;
int h[MAXN][MAXN], mn[MAXN][MAXN];
int que[MAXN];
inline void generalise() {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      h[i][j] = _g;
      _g = ((long long)_g * _x % _z + _y) % _z;
    }
  }
}
inline long long calc() {
  for (int i = 1; i <= n; ++i) {
    int head = 1, tail = 0;
    for (int j = 1; j < b; ++j) {
      while (head <= tail && h[i][que[tail]] >= h[i][j]) --tail;
      que[++tail] = j;
    }
    for (int j = b; j <= m; ++j) {
      while (head <= tail && h[i][que[tail]] >= h[i][j]) --tail;
      que[++tail] = j;
      while (head <= tail && que[head] < j - b + 1) ++head;
      mn[i][j] = head <= tail ? h[i][que[head]] : INF;
    }
  }
  long long ret = 0;
  for (int i = b; i <= m; ++i) {
    int head = 1, tail = 0;
    for (int j = 1; j < a; ++j) {
      while (head <= tail && mn[que[tail]][i] >= mn[j][i]) --tail;
      que[++tail] = j;
    }
    for (int j = a; j <= n; ++j) {
      while (head <= tail && mn[que[tail]][i] >= mn[j][i]) --tail;
      que[++tail] = j;
      while (head <= tail && que[head] < j - a + 1) ++head;
      ret += head <= tail ? mn[que[head]][i] : INF;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  scanf("%d%d%d%d", &_g, &_x, &_y, &_z);
  generalise();
  printf("%lld", calc());
  return 0;
}
