Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by n sectors, and the outer area is equally divided by m sectors. A wall exists between each pair of sectors of same area (inner or outer), but there is no wall between the inner area and the outer area. A wall always exists at the 12 o'clock position.

<image>

The inner area's sectors are denoted as (1,1), (1,2), ..., (1,n) in clockwise direction. The outer area's sectors are denoted as (2,1), (2,2), ..., (2,m) in the same manner. For a clear understanding, see the example image above.

Amugae wants to know if he can move from one sector to another sector. He has q questions.

For each question, check if he can move between two given sectors.

Input

The first line contains three integers n, m and q (1 ≤ n, m ≤ 10^{18}, 1 ≤ q ≤ 10^4) — the number of sectors in the inner area, the number of sectors in the outer area and the number of questions.

Each of the next q lines contains four integers s_x, s_y, e_x, e_y (1 ≤ s_x, e_x ≤ 2; if s_x = 1, then 1 ≤ s_y ≤ n, otherwise 1 ≤ s_y ≤ m; constraints on e_y are similar). Amague wants to know if it is possible to move from sector (s_x, s_y) to sector (e_x, e_y).

Output

For each question, print "YES" if Amugae can move from (s_x, s_y) to (e_x, e_y), and "NO" otherwise.

You can print each letter in any case (upper or lower).

Example

Input


4 6 3
1 1 2 3
2 6 1 2
2 6 2 4


Output


YES
NO
YES

Note

Example is shown on the picture in the statement.
import java.io.*;
import java.util.*;
 
public class tr1 {
	static PrintWriter out;
	static StringBuilder sb;
	static int inf = (int) 1e9;
	static int mod = (int) 1e9 + 7;
	static int[] si;
	static ArrayList<Integer> primes;
	static HashSet<Integer> pr;
	static int n, k, m;
	static boolean[] in;
	static HashMap<Integer, Integer> factors;
	static HashSet<Integer> f;
	static long[] fac;
	static int[] l, r;
	static long[][] memo;
	static int[] a;
	static ArrayList<Integer>[] ad;
	static HashMap<Integer, Integer> hm;
	static pair[] ed;
	static ArrayList<Integer>[] np;
	static TreeMap<pair, Integer> tm;
	static int[] ans, h1, h2;
	static char[] h;
	static int[] po;
    static TreeMap<Long,Long> kmp;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
	    long n=sc.nextLong();
	    long m=sc.nextLong();
	    long d=gcd(n,m);
	    long nf=n/d;
	    long mf=m/d;
	    int q=sc.nextInt();
	    while(q-->0) {
	    	int x=sc.nextInt();
	    	long y=sc.nextLong();
	    	if(x==1) {
	    		y=(y-1)/nf;
	    	}
	    	else {
	    		y=(y-1)/mf;
	    	}
	    	int x1=sc.nextInt();
	    	long y1=sc.nextLong();
	    	if(x1==1) {
	    		y1=(y1-1)/nf;
	    	}
	    	else {
	    		y1=(y1-1)/mf;
	    	}
	    	if(y==y1)
	    		out.println("YES");
	    	else
	    		out.println("NO");
	    }
		out.flush();
	}
	static int c = 0;
	static boolean ff;
	static Queue<StringBuilder> sq;
 
	static void sol(int i) {
		// System.out.println(i+" i");
		if (i == 0) {
			if (ff) {
				sol(i + 1);
			}
		} else if (i == n) {
			sb = new StringBuilder();
			for (int l : ans)
				sb.append(l + "");
			c++;
			// System.out.println(c);
			sq.add(sb);
			if (c == k)
				ff = false;
		} else {
			for (int y = 0; y < np[i].size(); y++) {
				ans[np[i].get(y)] = 1;
				if (ff) {
					sol(i + 1);
					ans[np[i].get(y)] = 0;
				}
				if (!ff)
					return;
			}
		}
	}
 
	static class pair {
		int x;
		int y;
		int num;
 
		pair(int f, int t, int n) {
			x = f;
			y = t;
			num = n;
		}
 
		public String toString() {
			return x + " " + y + " " + num;
		}
	}
 
	public int[] merge(int[] d, int st, int e) {
		if (st > e)
			return null;
		if (e == st) {
			int[] ans = { d[e] };
			return ans;
		}
		int mid = (st + e) / 2;
		int[] ans = new int[e - st + 1];
		int[] ll = merge(d, st, mid);
		int[] rr = merge(d, mid + 1, e);
		if (ll == null)
			return rr;
		if (rr == null)
			return ll;
		int iver = 0;
		int idxl = 0;
		int idxr = 0;
		for (int i = st; i <= e; i++) {
			if (ll[idxl] < rr[idxr]) {
 
			}
		}
		return ans;
	}
 
	public static class pair1 implements Comparable<pair1> {
		int a;
		int idx;
 
		pair1(int a, int i) {
			this.a = a;
			idx = i;
		}
 
		public String toString() {
			return a + " " + idx;
		}
 
		@Override
		public int compareTo(pair1 o) {
			return o.a - a;
		}
	}
 
	public static class pair2 implements Comparable<pair2> {
		int a;
		int idx;
 
		pair2(int a, int i) {
			this.a = a;
			idx = i;
		}
 
		public String toString() {
			return a + " " + idx;
		}
 
		@Override
		public int compareTo(pair2 o) {
			// TODO Auto-generated method stub
			return idx - o.idx;
		}
	}
 
	static int inver(long x) {
		int a = (int) x;
		int e = (13 - 2);
		int res = 1;
		while (e > 0) {
			if ((e & 1) == 1) {
				// System.out.println(res*a);
				res = (int) ((1l * res * a) % 13);
			}
			a = (int) ((1l * a * a) % 13);
			e >>= 1;
		}
		// out.println(res+" "+x);
		return res % 13;
	}
 
	static int atMostSum(int arr[], int n, int k) {
		int sum = 0;
		int cnt = 0, maxcnt = 0;
 
		for (int i = 0; i < n; i++) {
 
			// If adding current element doesn't
			// cross limit add it to current window
			if ((sum + arr[i]) <= k) {
				sum += arr[i];
				cnt++;
			}
 
			// Else, remove first element of current
			// window and add the current element
			else if (sum != 0) {
				sum = sum - arr[i - cnt] + arr[i];
			}
 
			// keep track of max length.
			maxcnt = Math.max(cnt, maxcnt);
		}
		return maxcnt;
	}
 
	public static int[] longestSubarray(int[] inp) {
		// array containing prefix sums up to a certain index i
		int[] p = new int[inp.length];
		p[0] = inp[0];
		for (int i = 1; i < inp.length; i++) {
			p[i] = p[i - 1] + inp[i];
		}
 
		// array Q from the description below
		int[] q = new int[inp.length];
		q[inp.length - 1] = p[inp.length - 1];
		for (int i = inp.length - 2; i >= 0; i--) {
			q[i] = Math.max(q[i + 1], p[i]);
		}
		int a = 0;
		int b = 0;
		int maxLen = 0;
		int curr;
		int[] res = new int[] { -1, -1 };
		while (b < inp.length) {
			curr = a > 0 ? q[b] - p[a - 1] : q[b];
			if (curr >= 0) {
				if (b - a > maxLen) {
					maxLen = b - a;
					res = new int[] { a, b };
				}
				b++;
			} else {
				a++;
			}
		}
		return res;
	}
 
	static void factor(int n) {
		if (si[n] == n) {
			f.add(n);
			return;
		}
		f.add(si[n]);
		factor(n / si[n]);
	}
 
	static void seive() {
		si = new int[1000001];
		primes = new ArrayList<>();
		int N = 1000001;
		si[1] = 1;
		for (int i = 2; i < N; i++) {
			if (si[i] == 0) {
				si[i] = i;
				primes.add(i);
			}
			for (int j = 0; j < primes.size() && primes.get(j) <= si[i] && (i * primes.get(j)) < N; j++)
				si[primes.get(j) * i] = primes.get(j);
 
		}
	}
	static long gcd(long a, long b) {
 
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
 
	static class unionfind {
		int[] p;
		int[] size;
 
		unionfind(int n) {
			p = new int[n];
			size = new int[n];
 
			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			Arrays.fill(size, 1);
		}
 
		int findSet(int v) {
			if (v == p[v])
				return v;
			return p[v] = findSet(p[v]);
		}
 
		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}
 
		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}
 
		void combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return;
			if (size[a] > size[b]) {
				p[b] = a;
				size[a] += size[b];
 
			} else {
				p[a] = b;
				size[b] += size[a];
			}
		}
	}
 
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}