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 javax.swing.plaf.basic.BasicScrollPaneUI;
import java.io.*;
import java.util.*;

public class Main {


    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private final DataInputStream din;
        private final byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[100000 + 1]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }
            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            din.close();
        }
    }

    static Reader sc = new Reader();
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));


    public static void main(String[] args) throws IOException {

        long n = sc.nextLong();
        long m = sc.nextLong();
        long aa = gcd(n, m);
        //System.out.println(aa);
        n = n / aa;
        m = m / aa;
        int q = sc.nextInt();
        // long aa=(long)Math.ceil(n/(double)m);
        for (int i = 0; i < q; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            long c = sc.nextLong();
            long d = sc.nextLong();
            if (x == c && x == 1) {

                long a1 = 0;
                long a2 = 0;
                long b1 = 0;
                long b2 = 0;

                if (y % n == 0) {
                    a1 = y / n - 1;
                    b1 = m * a1 + 1;
                    b2 = m * a1 + m;
                    a2 = a1 * n + 1;
                    a1 = a2;
                    a2 = y;


                } else {
                    a1 = y / n;
                    b1 = a1 * m + 1;
                    a2 = a1 * n + 1;

                    a1 = a2;
                    a2 = (y / n + 1) * n;
                    b2 = (y / n + 1) * m;
                }
                if (y <= a2 && y >= a1 && d <= a2 && d >= a1) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }


                continue;
            }
            if (x == c && x == 2) {
                long a1 = 0;
                long a2 = 0;
                long b1 = 0;
                long b2 = 0;
                if (y % m == 0) {

                    a1 = y / m - 1;
                    b1 = m * a1 + 1;
                    b2 = m * a1 + m;
                    a2 = a1 * m + 1;
                    a1 = a2;
                    a2 = y;


                } else {
                    a1 = y / m;
                    b1 = a1 * m + 1;
                    a2 = a1 * m + 1;

                    a1 = a2;
                    a2 = (y / m + 1) * m;
                    b2 = (y / m + 1) * m;
                }
                if (y <= a2 && y >= a1 && d <= a2 && d >= a1) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
                continue;
            }


            if (x != 1) {
                c = 2;
                x = 1;
                long temp = y;
                y = d;
                d = temp;

            }
            long a1 = 0;
            long a2 = 0;
            long b1 = 0;
            long b2 = 0;
            if (y % n == 0) {
                a1 = y / n - 1;
                b1 = m * a1 + 1;
                b2 = m * a1 + m;
                a2 = a1 * n + 1;
                a1 = a2;
                a2 = y;


            } else {
                a1 = y / n;
                b1 = a1 * m + 1;
                a2 = a1 * n + 1;

                a1 = a2;
                a2 = (y / n + 1) * n;
                b2 = (y / n + 1) * m;
            }


            if (y <= a2 && y >= a1 && d <= b2 && d >= b1) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }


        }


    }

    private static String printList(List<Integer> arr) {
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < arr.size(); i++) {
            if (i != arr.size() - 1) {
                ans.append(arr.get(i)).append(" ");
            } else {
                ans.append(arr.get(i));
            }
        }
        return ans.toString();

    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    private static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }


    public static int getpa(int[] arr, int n, int k) {
        int ans = 0;
        Map<Integer, Integer> map = new HashMap<>();
        ;
        for (int i = 0; i < n; i++) {
            int a = arr[i];
            if (!map.containsKey(a)) {
                map.put(a, 1);
            } else {
                int aa = map.get(a);
                aa++;
                map.put(a, aa);
            }

        }
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            int a = entry.getKey();
            int f = entry.getValue();
            System.out.println(a + " " + f);
            if (map.containsKey(k - a)) {
                System.out.println(map.get(k - a));
                ans += Math.max(f, map.get(k - a));
                map.put(a, 0);
            }
        }
        return ans;
    }

    public static String printArray(int[] arr) {

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < arr.length; i++) {
            if (i != arr.length - 1) {
                ans.append(arr[i]).append(" ");
            } else {
                ans.append(arr[i]);
            }
        }
        return ans.toString();
    }
}