#include <bits/stdc++.h>
using namespace std;
struct MinQueue {
  stack<pair<long long, long long>> s1, s2;
  long long get_min() {
    if (s1.empty() || s2.empty())
      return s1.empty() ? s2.top().second : s1.top().second;
    else
      return min(s1.top().second, s2.top().second);
  }
  void push(long long x) {
    s1.push({x, s1.empty() ? x : min(x, s1.top().second)});
  }
  void pop() {
    if (s2.empty()) {
      while (!s1.empty()) {
        long long element = s1.top().first;
        s1.pop();
        long long minimum =
            s2.empty() ? element : min(element, s2.top().second);
        s2.push({element, minimum});
      }
    }
    int remove_element = s2.top().first;
    s2.pop();
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  long long cur, x, y, z;
  cin >> cur >> x >> y >> z;
  vector<vector<long long>> mat(n, vector<long long>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      mat[i][j] = cur;
      cur = (cur * x + y) % z;
    }
  }
  vector<vector<long long>> row_min(n, vector<long long>(m - b + 1));
  for (int i = 0; i < n; i++) {
    MinQueue mine;
    for (int j = 0; j < b; j++) {
      mine.push(mat[i][j]);
    }
    row_min[i][0] = mine.get_min();
    for (int j = b; j < m; j++) {
      mine.push(mat[i][j]);
      mine.pop();
      row_min[i][j - b + 1] = mine.get_min();
    }
  }
  long long ans = 0;
  for (int i = 0; i < m - b + 1; i++) {
    MinQueue mine;
    for (int j = 0; j < a; j++) {
      mine.push(row_min[j][i]);
    }
    ans += mine.get_min();
    for (int j = a; j < n; j++) {
      mine.push(row_min[j][i]);
      mine.pop();
      ans += mine.get_min();
    }
  }
  cout << ans << '\n';
  return 0;
}
