Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size n × m cells on a map (rows of grid are numbered from 1 to n from north to south, and columns are numbered from 1 to m from west to east). After that he measured the average height of each cell above Rybinsk sea level and obtained a matrix of heights of size n × m. The cell (i, j) lies on the intersection of the i-th row and the j-th column and has height h_{i, j}. 

Seryozha is going to look at the result of his work in the browser. The screen of Seryozha's laptop can fit a subrectangle of size a × b of matrix of heights (1 ≤ a ≤ n, 1 ≤ b ≤ m). Seryozha tries to decide how the weather can affect the recreation center — for example, if it rains, where all the rainwater will gather. To do so, he is going to find the cell having minimum height among all cells that are shown on the screen of his laptop.

Help Seryozha to calculate the sum of heights of such cells for all possible subrectangles he can see on his screen. In other words, you have to calculate the sum of minimum heights in submatrices of size a × b with top left corners in (i, j) over all 1 ≤ i ≤ n - a + 1 and 1 ≤ j ≤ m - b + 1.

Consider the sequence g_i = (g_{i - 1} ⋅ x + y) mod z. You are given integers g_0, x, y and z. By miraculous coincidence, h_{i, j} = g_{(i - 1) ⋅ m + j - 1} ((i - 1) ⋅ m + j - 1 is the index).

Input

The first line of the input contains four integers n, m, a and b (1 ≤ n, m ≤ 3 000, 1 ≤ a ≤ n, 1 ≤ b ≤ m) — the number of rows and columns in the matrix Seryozha has, and the number of rows and columns that can be shown on the screen of the laptop, respectively.

The second line of the input contains four integers g_0, x, y and z (0 ≤ g_0, x, y < z ≤ 10^9).

Output

Print a single integer — the answer to the problem.

Example

Input


3 4 2 1
1 2 3 59


Output


111

Note

The matrix from the first example: 

<image>
import java.util.*;
import java.io.*;
import java.math.*;

public class round574d2e {

	public static void main(String args[]) {
		FastScanner in = new FastScanner(System.in);
		
		int n = in.nextInt();
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int g0 = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int z = in.nextInt();
		
		long g = g0;
		int[] gs = new int[(n-1)*m+m];
		for (int i = 0; i < gs.length; i++) {
			gs[i] = (int)g;
			g = g * x + y;
			g %= z;
		}
		int[][] hs = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				hs[i][j] = gs[(i)*m+j];
			}
		}
		//System.out.println(Arrays.deepToString(hs));
		
		int[][] boxes = new int[n][m];
		int[][] shards = new int[n][m];
		int tempMin = Integer.MAX_VALUE;
		/*for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				boxes[0][0] = Integer.min(tempMin, hs[i][j]);
			}
		}*/
		int[] horShards = new int[n];
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			for (int j = 0; j < b; j++) {
				min = Integer.min(min, hs[i][j]);
			}
			horShards[i] = min;
		}
		for (int j = 0; j < m; j++) {
			ArrayDeque<Integer> deque = new ArrayDeque<>();
			for (int i = 0; i < a; i++) {
				int next = hs[i][j];
				while (!deque.isEmpty()) {
					if (deque.getLast() > next) {
						deque.pollLast();
					}
					else {
						break;
					}
				}
				deque.addLast(next);
			}
			shards[0][j] = deque.getFirst();
			for (int i = 1; i <= n-a; i++) {
				int prev = hs[i-1][j];
				if (deque.getFirst() == prev) {
					deque.pollFirst();
				}
				int next = hs[i+a-1][j];
				while (!deque.isEmpty()) {
					if (deque.getLast() > next) {
						deque.pollLast();
					}
					else {
						break;
					}
				}
				deque.addLast(next);
				shards[i][j] = deque.getFirst();
			}
			
		}
		//ArrayDeque<Integer> deq = new ArrayDeque<>();
		/*for (int i = 0; i < a; i++) {
			int next = horShards[i];
			while (!deq.isEmpty()) {
				if (deq.getLast() > next) {
					deq.pollLast();
				}
				else {
					break;
				}
			}
			deq.addLast(next);
		}*/
		//if (deq.getFirst() != boxes[0][0]) throw new InputMismatchException("problemo");
		//System.out.println(deq.getFirst());
		
		//boxes[0][0] = deq.getFirst();
		/*for (int i = 1; i <= n-a; i++) {
			int prev = horShards[i-1];
			if (deq.getFirst() == prev) {
				deq.pollFirst();
			}
			int next = horShards[i+a-1];
			while (!deq.isEmpty()) {
				if (deq.getLast() > next) {
					deq.pollLast();
				}
				else {
					break;
				}
			}
			deq.addLast(next);
			boxes[i][0] = deq.getFirst();
		}*/
		
		for (int i = 0; i <=n-a; i++) {
			ArrayDeque<Integer> deque = new ArrayDeque<>();
			for (int j = 0; j < b; j++) {
				int next = shards[i][j];
				while (!deque.isEmpty()) {
					if (deque.getLast() > next) {
						deque.pollLast();
					}
					else {
						break;
					}
				}
				deque.addLast(next);
			}
			boxes[i][0] = deque.getFirst();
			for (int j = 1; j <= m -b; j++) {
				int prev = shards[i][j-1];
				if (deque.getFirst() == prev) {
					deque.pollFirst();
				}
				int next = shards[i][j+b-1];
				while (!deque.isEmpty()) {
					if (deque.getLast() > next) {
						deque.pollLast();
					}
					else {
						break;
					}
				}
				deque.addLast(next);
				boxes[i][j] = deque.getFirst();
			}
		}
		long sum = 0;
		for (int i = 0; i <= n-a; i++) {
			for (int j = 0; j <= m-b; j++) {
				sum += boxes[i][j];
			}
		}
		//System.out.println(Arrays.deepToString(shards));
		//System.out.println(Arrays.deepToString(boxes));
		System.out.println(sum);

	}

	// ======================================================================================
	// =============================== Reference Code =======================================
	// ======================================================================================

	static int greatestDivisor(int n) {
		int limit = (int) Math.sqrt(n);
		int max = 1;
		for (int i = 2; i <= limit; i++) {
			if (n % i == 0) {
				max = Integer.max(max, i);
				max = Integer.max(max, n / i);
			}
		}
		return max;
	}

	// Method to return all primes smaller than or equal to 
	// n using Sieve of Eratosthenes 
	static boolean[] sieveOfEratosthenes(int n) {
		// Create a boolean array "prime[0..n]" and initialize 
		// all entries it as true. A value in prime[i] will 
		// finally be false if i is Not a prime, else true. 
		boolean prime[] = new boolean[n + 1];
		for (int i = 0; i <= n; i++)
			prime[i] = true;

		prime[0] = false;
		prime[1] = false;

		for (int p = 2; p * p <= n; p++) {
			// If prime[p] is not changed, then it is a prime 
			if (prime[p] == true) {
				// Update all multiples of p 
				for (int i = p * p; i <= n; i += p)
					prime[i] = false;
			}
		}

		return prime;
	}

	// Binary search for number greater than or equal to target
	// returns -1 if number not found
	private static int bin_gteq(int[] a, int key) {
		int low = 0;
		int high = a.length;
		int max_limit = high;
		while (low < high) {
			int mid = low + (high - low) / 2;
			if (a[mid] < key) {
				low = mid + 1;
			} else
				high = mid;
		}

		return high == max_limit ? -1 : high;
	}

	public static int gcd(int a, int b) {
		if (a == 0)
			return b;

		return gcd(b % a, a);
	}

	static class Tuple<X, Y> {
		public final X x;
		public final Y y;

		public Tuple(X x, Y y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return "(" + x + "," + y + ")";
		}
	}

	static class Tuple3<X, Y, Z> {
		public final X x;
		public final Y y;
		public final Z z;

		public Tuple3(X x, Y y, Z z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return "(" + x + "," + y + "," + z + ")";
		}
	}

	static Tuple3<Integer, Integer, Integer> gcdExtended(int a, int b, int x, int y) {
		// Base Case 
		if (a == 0) {
			x = 0;
			y = 1;
			return new Tuple3(0, 1, b);
		}

		int x1 = 1, y1 = 1; // To store results of recursive call 
		Tuple3<Integer, Integer, Integer> tuple = gcdExtended(b % a, a, x1, y1);
		int gcd = tuple.z;
		x1 = tuple.x;
		y1 = tuple.y;

		// Update x and y using results of recursive 
		// call 
		x = y1 - (b / a) * x1;
		y = x1;

		return new Tuple3(x, y, gcd);
	}

	// Returns modulo inverse of a  
	// with respect to m using extended 
	// Euclid Algorithm. Refer below post for details: 
	// https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ 
	static int inv(int a, int m) {
		int m0 = m, t, q;
		int x0 = 0, x1 = 1;

		if (m == 1)
			return 0;

		// Apply extended Euclid Algorithm 
		while (a > 1) {
			// q is quotient 
			q = a / m;

			t = m;

			// m is remainder now, process 
			// same as euclid's algo 
			m = a % m;
			a = t;

			t = x0;

			x0 = x1 - q * x0;

			x1 = t;
		}

		// Make x1 positive 
		if (x1 < 0)
			x1 += m0;

		return x1;
	}

	// k is size of num[] and rem[]. 
	// Returns the smallest number 
	// x such that: 
	// x % num[0] = rem[0], 
	// x % num[1] = rem[1], 
	// .................. 
	// x % num[k-2] = rem[k-1] 
	// Assumption: Numbers in num[] are pairwise  
	// coprime (gcd for every pair is 1) 
	static int findMinX(int num[], int rem[], int k) {
		// Compute product of all numbers 
		int prod = 1;
		for (int i = 0; i < k; i++)
			prod *= num[i];

		// Initialize result 
		int result = 0;

		// Apply above formula 
		for (int i = 0; i < k; i++) {
			int pp = prod / num[i];
			result += rem[i] * inv(pp, num[i]) * pp;
		}

		return result % prod;
	}

	/**
	 * Source: Matt Fontaine
	 */
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int chars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		int read() {
			if (chars == -1)
				throw new InputMismatchException();
			if (curChar >= chars) {
				curChar = 0;
				try {
					chars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (chars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}