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.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class E3 {

	static long N,M,X,Y,dX,dY;
	public static void main(String[] args) {
		//System.out.println(modInv(2, 6));

		JS in = new JS();
		N = in.nextLong();
		M = in.nextLong();
		X = in.nextLong();
		Y = in.nextLong();
		dX = in.nextLong();
		dY = in.nextLong();

		
		if(dX == 1 && dY == 0) { //going right
			if(Y == M) System.out.println(N+" "+M);
			else if(Y == 0) System.out.println(N+" "+0);
			else System.out.println(-1);
		}
		else if(dX == -1 && dY == 0) { //going left
			if(Y == M) System.out.println(0+" "+M);
			else if(Y==0)System.out.println(0+" "+0);
			else System.out.println(-1);
		}
		else if(dX == 0 && dY == 1) { //going up
			if(X==0) System.out.println(0+" "+M);
			else if(X==N) System.out.println(N+" "+M);
			else System.out.println(-1);
		}
		else if(dX == 0 && dY == -1) { //going down
			if(X==0) System.out.println(0+" "+0);
			else if(X==N) System.out.println(N+" "+0);
			else System.out.println(-1);
		}
		else {
			if(dX == 1 && dY == 1) {
				go1(N,M,X,Y);
			}
			else if(dX == 1 && dY == -1) { //down-right
				go2(N,M,X,M-Y);	
			}
			else if(dX == -1 && dY == 1) { //up-left
				go3(N,M,N-X,Y);
			}
			else if(dX == -1 && dY == -1) { //down-left
				go4(N,M,N-X,M-Y);
			}
		}
		
		
	}
	
	static void go4(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);
		
		long x2 = N*2;
		long y2 = y1 + N;
		
		long mod1 = y1%M;
		long mod2 = y2%M;
		
		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(2);
			else hole(0);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(3);
			else hole(1);
			return;
		}
		
		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}
		
		if(dif < 0) {
			dif = M+dif;
		}
		
		//System.out.println("H: "+mod1+" "+dif+" "+M);
		
		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}
		
		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(2);
			else hole(0);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(3);
			else hole(1);
		}	
	}
	
	static void go3(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);
		
		long x2 = N*2;
		long y2 = y1 + N;
		
		long mod1 = y1%M;
		long mod2 = y2%M;
		
		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(0);
			else hole(2);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(1);
			else hole(3);
			return;
		}
		
		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}
		
		if(dif < 0) {
			dif = M+dif;
		}
		
		//System.out.println("H: "+mod1+" "+dif+" "+M);
		
		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}
		
		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(0);
			else hole(2);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(1);
			else hole(3);
		}	
	}
	
	static void go2(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);
		
		long x2 = N*2;
		long y2 = y1 + N;
		
		long mod1 = y1%M;
		long mod2 = y2%M;
		
		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(3);
			else hole(1);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(2);
			else hole(0);
			return;
		}
		
		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}
		
		if(dif < 0) {
			dif = M+dif;
		}
		
		//System.out.println("H: "+mod1+" "+dif+" "+M);
		
		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}
		
		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(3);
			else hole(1);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(2);
			else hole(0);
		}		
	}
	
	static void go1(long N, long M, long X, long Y) {
		long x1 = N;
		long y1 = Y + (N-X);
		
		long x2 = N*2;
		long y2 = y1 + N;
		
		long mod1 = y1%M;
		long mod2 = y2%M;
		
		if(mod1==0) {
			if( (y1/M)%2 == 0)hole(1);
			else hole(3);
			return;
		}
		if(mod2==0) {
			if( (y2/M) % 2 == 0) hole(0);
			else hole(2);
			return;
		}
		
		long dif = mod2-mod1;
		if(dif == 0) {
			System.out.println(-1);
			return;
		}
		
		if(dif < 0) {
			dif = M+dif;
		}
		
		//System.out.println("H: "+mod1+" "+dif+" "+M);
		
		long gcd = gcd(dif,M);
		long res = -1;
		if(gcd==1) {//coprime
			res = ((M-mod1)*modInv(dif,M))%M;
		}
		else {//not coprime
			//increment by gcd
			res = bs(0, M/gcd, mod1, gcd, M);
			if(res==-1) {
				System.out.println(-1);
				return;
			}
			res = ((M/gcd-mod1/gcd)*modInv(dif/gcd,M/gcd))%(M/gcd);
		}
		//System.out.println(res+" "+(y1+N*res));
		
		if(res%2==0) { // 1-3 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0 ) hole(1);
			else hole(3);
		}
		else {		//0-2 case
			long newY = y1 + N*res;
			if( (newY/M)%2==0)hole(0);
			else hole(2);
		}		
	}
	
	static void hole(int n) {
		if(n==0)System.out.println(0+" "+0);
		if(n==1)System.out.println(N+" "+0);
		if(n==2)System.out.println(0+" "+M);
		if(n==3)System.out.println(N+" "+M);
	}

	
	
	
	static long bs(long lo, long hi, long st, long dif, long M) {
		//System.out.println("BS: "+lo+" "+hi+" "+st+" "+dif+" "+M);
		if(lo==hi) {
			if( (st+dif*lo)%M == 0) return lo;
			return -1;
		}
		if(lo+1==hi) {
			if( (st+dif*lo)%M == 0) return lo;
			if( (st+dif*hi)%M == 0) return hi;
			return -1;
		}
		long mid = (lo+hi)/2;
		if( st + dif*mid > M) return bs(lo, mid, st, dif, M);
		return bs(mid, hi, st, dif,M);
		
	}
	
	static boolean coPrime(long x, long y) {
		return gcd(x,y)==1;
	}
	
	static long modInv(long x, long mod) {
		if(x == 1) return 1;
		if(gcd(x, mod) != 1) return 0;
		long r = mod % x;
		//return modInv(r, x % r, 0, 1, mod / x, x / r);
		return Math.floorMod(modInv(r, x % r, 0, 1, mod / x, x / r), mod);
	}

	static long modInv(long a, long b, long y0, long y1, long q0, long q1) {
		long y2 = y0 - y1*q0;
		return b == 0 ? y2 : modInv(b, a % b, y1, y2, q1, a / b);
	}

	static long gcd(long a, long b) {
		return b==0?a:gcd(b, a%b);
	}
	static long lcm(long a, long b) {
		return a * (b/gcd(a,b));
	}
	
	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;
		
		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}
		
		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}
		
		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}				
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}
		
		public int nextInt() {
			return (int)nextLong();
		}
		
		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}
		
		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}
		
		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}
		
		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int []nia(int n){
			int r[] = new int[n];
			for(int i = 0; i < n; i++) r[i] = nextInt();
			return r;
		}
		public double []nda(int n){
			double r[] = new double[n];
			for(int i = 0; i < n; i++) r[i] = nextDouble();
			return r;
		}
		public long []nla(int n){
			long r[] = new long[n];
			for(int i = 0; i < n; i++) r[i] = nextLong();
			return r;
		}
	}
	
}