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 E982{

	private void solve() throws Exception {
		long n = nextLong();
		long m = nextLong();
		long i = nextLong();
		long j = nextLong();
		long vi = nextLong();
		long vj = nextLong();
		long[] resX = new long[]{0,n};
		long[] resY = new long[]{0,m};
		if(vi == 0) {
			if(i == 0 && vj == 1) out.println(0 + " " + m);
			else if(i == 0 && vj == -1) out.println(0 + " " + 0);
			else if(i == n && vj == 1) out.println(n + " " + m);
			else if(i == n && vj == -1) out.println(n + " " + 0);
			else out.println(-1);
		} else if (vj == 0) {
			if(j == 0 && vi == 1) out.println(n + " " + 0);
			else if(j == 0 && vi == -1) out.println(0 + " " + 0);
			else if(j == m && vi == 1) out.println(n + " " + m);
			else if(j == m && vi == -1) out.println(0 + " " + m);
			else out.println(-1);
		} else {
			if(vi < 0) i = n-i;
			if(vj < 0) j = m-j;
			long ii = (n-i)%n;
			long jj = (m-j)%m;
			long d = gcd(m,n);
			if(ii%d == jj%d) {
				HashMap<Long, Integer> factorsM = factors(m);
				HashMap<Long, Integer> factorsN = factors(n);
				long nn = 1;
				for(Long f : factorsN.keySet()) if(!factorsM.containsKey(f) || factorsN.get(f) >= factorsM.get(f)) nn *= pow(f, factorsN.get(f));
				
				long mm = 1;
				for(Long f : factorsM.keySet()) if(!factorsN.containsKey(f) || factorsM.get(f) > factorsN.get(f)) mm *= pow(f, factorsM.get(f));
				
				
				long t = chineseRemainder(new long[] {nn, mm}, new long[] {ii%nn, jj%mm});
				long x = (i+t)/n;
				int rx = 0;
				if(x%2 == 1) rx = 1-rx;
				if(vi < 0) rx = 1-rx;
				
				long y = (j+t)/m;
				int ry = 0;
				if(y%2 == 1) ry = 1-ry;
				if(vj < 0) ry = 1-ry;
				out.println(resX[rx] + " " + resY[ry]);
			} else out.println(-1);
		}
	}
	
	long pow(long m, int n)
	{
	    long res = 1;
	    while(n > 0){
	        if(n % 2 == 1)res = res*m;
	        m = m*m;
	        n = n/2;
	    }
	    return res;
	}
	
	long prod(long m, long n, long mod)
	{
	    long res = 0;
	    while(n > 0){
	        if(n % 2 == 1)res = (res+m)%mod;
	        m = (m+m)%mod;
	        n = n/2;
	    }
	    return res%mod;
	} 
	
	HashMap<Long, Integer> factors(long p){
		HashMap<Long, Integer> factors = new HashMap<Long, Integer>();
		long x = 2;
		while(x*x <= p) {
			int y = 0;
			while(p%x == 0) {
				p /= x;
				y++;
			}
			if(y != 0) factors.put(x,y);
			x++;
		}
		if(p != 1) factors.put(p, 1);
		return factors;
	}
	
	long chineseRemainder(long[] mods, long[] a) {
		int k = mods.length;
		long n = 1;
		for(long mod : mods) n = n*mod;
		long[] n_ = new long[k];
		long[] e = new long[k];
		for(int i = 0; i < k; i++) {
			n_[i] = n/mods[i];
			e[i] = ((n_[i]%n)*(inverse(n_[i]%mods[i], mods[i]))%n)%n;
		}
		long res = 0;
		for(int i = 0; i < k; i++) res = (res + prod(a[i]%mods[i], e[i], n))%n;
		
		return res%n;
	}

	long inverse(long n, long mod) {
		long i = mod, v = 0, d = 1;
		while (n>0) {
			long t = i/n, x = n;
			n = i % x;
			i = x;
			x = d;
			d = v - t*x;
			v = x;
		}
		v %= mod;
		return (v+mod)%mod;
	}

	long gcd(long a, long b){
		while(b > 0){
			long t = b;
			b = a%b;
			a = t;
		}
		return a;
	}




	public static void main(String[] args) {
		(new E982()).run();
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private float nextFloat() throws IOException {
		return Float.parseFloat(nextToken());
	}

	private String nextLine() throws IOException {
		return new String(in.readLine());
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(in.readLine());
		}
		return tokenizer.nextToken();
	}


}