[THE SxPLAY & KIVΛ - 漂流](https://soundcloud.com/kivawu/hyouryu)

[KIVΛ & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives)

With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.

The space can be considered a 2D plane, with an infinite number of data nodes, indexed from 0, with their coordinates defined as follows:

  * The coordinates of the 0-th node is (x_0, y_0) 
  * For i > 0, the coordinates of i-th node is (a_x ⋅ x_{i-1} + b_x, a_y ⋅ y_{i-1} + b_y) 



Initially Aroma stands at the point (x_s, y_s). She can stay in OS space for at most t seconds, because after this time she has to warp back to the real world. She doesn't need to return to the entry point (x_s, y_s) to warp home.

While within the OS space, Aroma can do the following actions:

  * From the point (x, y), Aroma can move to one of the following points: (x-1, y), (x+1, y), (x, y-1) or (x, y+1). This action requires 1 second. 
  * If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs 0 seconds. Of course, each data node can be collected at most once. 



Aroma wants to collect as many data as possible before warping back. Can you help her in calculating the maximum number of data nodes she could collect within t seconds?

Input

The first line contains integers x_0, y_0, a_x, a_y, b_x, b_y (1 ≤ x_0, y_0 ≤ 10^{16}, 2 ≤ a_x, a_y ≤ 100, 0 ≤ b_x, b_y ≤ 10^{16}), which define the coordinates of the data nodes.

The second line contains integers x_s, y_s, t (1 ≤ x_s, y_s, t ≤ 10^{16}) – the initial Aroma's coordinates and the amount of time available.

Output

Print a single integer — the maximum number of data nodes Aroma can collect within t seconds.

Examples

Input


1 1 2 3 1 0
2 4 20


Output


3

Input


1 1 2 3 1 0
15 27 26


Output


2

Input


1 1 2 3 1 0
2 2 1


Output


0

Note

In all three examples, the coordinates of the first 5 data nodes are (1, 1), (3, 3), (7, 9), (15, 27) and (31, 81) (remember that nodes are numbered from 0).

In the first example, the optimal route to collect 3 nodes is as follows: 

  * Go to the coordinates (3, 3) and collect the 1-st node. This takes |3 - 2| + |3 - 4| = 2 seconds. 
  * Go to the coordinates (1, 1) and collect the 0-th node. This takes |1 - 3| + |1 - 3| = 4 seconds. 
  * Go to the coordinates (7, 9) and collect the 2-nd node. This takes |7 - 1| + |9 - 1| = 14 seconds. 



In the second example, the optimal route to collect 2 nodes is as follows: 

  * Collect the 3-rd node. This requires no seconds. 
  * Go to the coordinates (7, 9) and collect the 2-th node. This takes |15 - 7| + |27 - 9| = 26 seconds. 



In the third example, Aroma can't collect any nodes. She should have taken proper rest instead of rushing into the OS space like that.
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class b {
/*
1 1 2 3 1 0   2 4 20
==> 3

1 1 2 3 1 0   15 27 26
==> 2

1 1 2 3 1 0   2 2 1
==> 0

LMAO THIS SHIT ACTUALLY BROKE ME
1 1 2 2 1 1   69 69 6969

 */
	static class Solver {
		
		long oo = (long) 1e18;
		
		long dist(long x1, long y1, long x2, long y2) {
			try {
				long d = 0;
				
				if (x1 > x2) d = Math.addExact(x1, -x2);
				else d = Math.addExact(x2, -x1);
				
				if (y1 > y2) d = Math.addExact(Math.addExact(y1, -y2), d);
				else d = Math.addExact(Math.addExact(y2, -y1), d);
				
				return d > oo ? oo : d;
			} catch(ArithmeticException ae) { return oo; }
		}
		
		int fwdBack(int ip, int d) {
			long cx = xs, cy = ys, trav = 0, dt;
			int res = 0;
			// to initial point
			if((dt = dist(cx, cy, points[ip][0], points[ip][1])) <= t) {
				trav = dt; cx = points[ip][0]; cy = points[ip][1]; res++;
			}
			// fwd
			for(int i = ip + 1, dd = 0; dd < d; i++, dd++) {
				if((dt = dist(cx, cy, points[i][0], points[i][1])) <= t - trav) {
					trav += dt; cx = points[i][0]; cy = points[i][1]; res++;
				}
			}
			// rev it up
			for(int i = ip - 1; i >= 0; i--) {
				if((dt = dist(cx, cy, points[i][0], points[i][1])) <= t - trav) {
					trav += dt; cx = points[i][0]; cy = points[i][1]; res++;
				}
			}
			return res;
		}
		
		int backFwd(int ip, int d) {
			long cx = xs, cy = ys, trav = 0, dt;
			int res = 0;
			// to initial point
			if((dt = dist(cx, cy, points[ip][0], points[ip][1])) <= t) {
				trav = dt; cx = points[ip][0]; cy = points[ip][1]; res++;
			}
			// rev it up
			for(int i = ip - 1, dd = 0; dd < d; i--, dd++) {
				if((dt = dist(cx, cy, points[i][0], points[i][1])) <= t - trav) {
					trav += dt; cx = points[i][0]; cy = points[i][1]; res++;
				}
			}
			// fwd
			for(int i = ip + 1; i < PL; i++) {
				if((dt = dist(cx, cy, points[i][0], points[i][1])) <= t - trav) {
					trav += dt; cx = points[i][0]; cy = points[i][1]; res++;
				}
			}
			return res;
		}
		
		long x0, y0, ax, ay, bx, by, xs, ys, t, points[][];
		ArrayList<long[]> pp; int PL;
		
		void solve(FastScanner s, PrintWriter out) {
			x0 = s.nextLong(); y0 = s.nextLong(); ax = s.nextLong(); ay = s.nextLong();
			bx = s.nextLong(); by = s.nextLong(); xs = s.nextLong(); ys = s.nextLong();
			t = s.nextLong(); // input much?

			long cx = x0, cy = y0; pp = new ArrayList<>();
			while(true) {
				try {
					pp.add(new long[] { cx, cy });
					cx = Math.addExact(Math.multiplyExact(cx, ax), bx);
					cy = Math.addExact(Math.multiplyExact(cy, ay), by);
				} catch(ArithmeticException ae) { break; }
			}
			
			
			PL = pp.size(); points = new long[PL][2];
			for(int i = 0; i < PL; i++) {
				points[i][0] = pp.get(i)[0];
				points[i][1] = pp.get(i)[1];
			}
			
//			for(long[] p : points)
//				out.printf("(%d, %d)%n", p[0], p[1]);
//			out.println(PL);
			
			int max = 0, pos;
			for(int ip = 0; ip < PL; ip++) {
				// fwd-back
				for(int fwd = PL - 1 - ip; fwd >= 0; fwd--) {
					pos = fwdBack(ip, fwd);
					if(pos > max) max = pos;
//					System.err.printf("fwd: from %d by %d and got %d%n", ip, fwd, pos);
				}
				// back-fwd
				for(int back = ip; back >= 0; back--) {
					pos = backFwd(ip, back);
					if(pos > max) max = pos;
//					System.err.printf("back: from %d by %d and got %d%n", ip, back, pos);
				}
			}
			out.println(max);
		}
		
	}
	
	public static void main(String[] args) {
		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new Solver().solve(s, out);
		out.close(); s.close();
	}
	
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1 << 22];
		private int curChar;
		private int numChars;
		
		public FastScanner(InputStream stream) {
			this.stream = stream;
		}
		
		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}
		
		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}
		
		void close() {
			try {
				stream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 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();
		}
		
		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}
		
		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}
		
		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}
		
		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}
		
		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}
		
		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}
		
	}
	
}
