Problem: Consider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size n × m with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). 

<image>

There is one ball at the point (x, y) currently. Max comes to the table and strikes the ball. The ball starts moving along a line that is parallel to one of the axes or that makes a 45^{\circ} angle with them. We will assume that: 

  1. the angles between the directions of the ball before and after a collision with a side are equal, 
  2. the ball moves indefinitely long, it only stops when it falls into a pocket, 
  3. the ball can be considered as a point, it falls into a pocket if and only if its coordinates coincide with one of the pockets, 
  4. initially the ball is not in a pocket. 



Note that the ball can move along some side, in this case the ball will just fall into the pocket at the end of the side.

Your task is to determine whether the ball will fall into a pocket eventually, and if yes, which of the four pockets it will be.

Input

The only line contains 6 integers n, m, x, y, v_x, v_y (1 ≤ n, m ≤ 10^9, 0 ≤ x ≤ n; 0 ≤ y ≤ m; -1 ≤ v_x, v_y ≤ 1; (v_x, v_y) ≠ (0, 0)) — the width of the table, the length of the table, the x-coordinate of the initial position of the ball, the y-coordinate of the initial position of the ball, the x-component of its initial speed and the y-component of its initial speed, respectively. It is guaranteed that the ball is not initially in a pocket.

Output

Print the coordinates of the pocket the ball will fall into, or -1 if the ball will move indefinitely.

Examples

Input

4 3 2 2 -1 1


Output

0 0

Input

4 4 2 0 1 1


Output

-1

Input

10 10 10 1 -1 0


Output

-1

Note

The first sample: 

<image>

The second sample: 

<image>

In the third sample the ball will never change its y coordinate, so the ball will never fall into a pocket.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Codeforces982D {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		int vx = Integer.parseInt(st.nextToken());
		int vy = Integer.parseInt(st.nextToken());
		
		if ((vx == 0) && (vy == 1)) {
			if (x == 0)
				System.out.println(0 + " " + m);
			else if (x == n) {
				System.out.println(n + " " + m);
			}
			else {
				System.out.println(-1);
			}
		}
		else if ((vx == 0) && (vy == -1)) {
			if (x == 0)
				System.out.println(0 + " " + 0);
			else if (x == n) {
				System.out.println(n + " " + 0);
			}
			else {
				System.out.println(-1);
			}
		}
		else if ((vx == 1) && (vy == 0)) {
			if (y == 0)
				System.out.println(n + " " + 0);
			else if (y == m) {
				System.out.println(n + " " + m);
			}
			else {
				System.out.println(-1);
			}
		}
		else if ((vx == -1) && (vy == 0)) {
			if (y == 0)
				System.out.println(0 + " " + 0);
			else if (y == m) {
				System.out.println(0 + " " + m);
			}
			else {
				System.out.println(-1);
			}
		}
		else {
			//want n|x \pm h, m|y \pm h
			int gcdmn = gcd(m, n);
			if (vx == vy) {
				//want n|x+h, m|y+h
				//so gcd(n, m)|x-y
				if (Math.abs(x-y)%gcdmn != 0) {
					System.out.println(-1);
				}
				else {
					//mk-y = nl-x
					//(x-y)+mk = nl
					int a1 = (x-y)/gcdmn;
					int a2 = m/gcdmn;
					int a3 = n/gcdmn;
					//a1+a2 k = a3 l
					int l = inverse(a3, a2);
					long r = (long) a1 * (long) l;
					l = (int) (r%a2);
					if (vx == 1) {
						if (l <= 0)
							l += a2;
						long kLong = ((long) n * (long) l - (long) (x-y))/((long) m);
						int k = (int) kLong;
						if ((l%2 == 0) && (k%2 == 0)) {
							System.out.println(0 + " " + 0);
						}
						if ((l%2 != 0) && (k%2 == 0)) {
							System.out.println(n + " " + 0);
						}
						if ((l%2 == 0) && (k%2 != 0)) {
							System.out.println(0 + " " + m);
						}
						if ((l%2 != 0) && (k%2 != 0)) {
							System.out.println(n + " " + m);
						}
					}
					else {
						if (l > 0)
							l -= a2;
						long kLong = ((long) n * (long) l - (long) (x-y))/((long) m);
						int k = (int) kLong;
						if ((l%2 == 0) && (k%2 == 0)) {
							System.out.println(0 + " " + 0);
						}
						if ((l%2 != 0) && (k%2 == 0)) {
							System.out.println(n + " " + 0);
						}
						if ((l%2 == 0) && (k%2 != 0)) {
							System.out.println(0 + " " + m);
						}
						if ((l%2 != 0) && (k%2 != 0)) {
							System.out.println(n + " " + m);
						}
					}
				}
			}
			else {
				//want n|x+h, m|h-y
				//so gcd(n, m)|x+y
				if (Math.abs(x+y)%gcdmn != 0) {
					System.out.println(-1);
				}
				else {
					//mk-y = x-nl
					//(x+y)+m(-k) = nl
					int a1 = (x+y)/gcdmn;
					int a2 = m/gcdmn;
					int a3 = n/gcdmn;
					//a1+a2 k = a3 l
					int l = inverse(a3, a2);
					long r = (long) a1 * (long) l;
					l = (int) (r%a2);
					if (vx == 1) {
						if (l <= 0)
							l += a2;
						long kLong = ((long) n * (long) l - (long) (x+y))/((long) m);
						int k = (int) kLong;
						if ((l%2 == 0) && (k%2 == 0)) {
							System.out.println(0 + " " + 0);
						}
						if ((l%2 != 0) && (k%2 == 0)) {
							System.out.println(n + " " + 0);
						}
						if ((l%2 == 0) && (k%2 != 0)) {
							System.out.println(0 + " " + m);
						}
						if ((l%2 != 0) && (k%2 != 0)) {
							System.out.println(n + " " + m);
						}
					}
					else {
						if (l > 0)
							l -= a2;
						long kLong = ((long) n * (long) l - (long) (x+y))/((long) m);
						int k = (int) kLong;
						if ((l%2 == 0) && (k%2 == 0)) {
							System.out.println(0 + " " + 0);
						}
						if ((l%2 != 0) && (k%2 == 0)) {
							System.out.println(n + " " + 0);
						}
						if ((l%2 == 0) && (k%2 != 0)) {
							System.out.println(0 + " " + m);
						}
						if ((l%2 != 0) && (k%2 != 0)) {
							System.out.println(n + " " + m);
						}
					}
				}
			}
		}
		
		pw.close();
	}
	
	public static int inverse (int a, int n) {
		int m = n;
		int r1 = 1;
		int r2 = 0;
		int r3 = 0;
		int r4 = 1;
		while ((a > 0) && (n > 0)) {
			if (n >= a) {
				r3 -= r1*(n/a);
				r4 -= r2*(n/a);
				n = n%a;
			}
			else {
				int tmp = a;
				a = n;
				n = tmp;
				tmp = r1;
				r1 = r3;
				r3 = tmp;
				tmp = r2;
				r2 = r4;
				r4 = tmp;
			}
		}
		if (a == 0) {
			if (r3 >= 0)
				return (r3%m);
			else
				return (m+(r3%m));
		}
		else {
			if (r1 >= 0)
				return (r1%m);
			else
				return (m+(r1%m));
		}

	}
	
	public static int gcd(int a, int b) {
		if (a == b) {
			return a;
		}
		else if ((a == 0) || (b == 0)) {
			return a+b;
		}
		else if (a > b) {
			return gcd(b, a%b);
		}
		else {
			return gcd(b, a);
		}
	}
}