/**
 * Задача "Морской бой"
 * Городская олимпиада школьников Санкт-Петербурга по программированию, 2009.
 * Авторы задачи: Федор Царев, Роман Сатюков.
 * Автор решения: Максим Буздалов.
 *
 * Решение, содержащее ошибку при работе с остатками в классификаторе.
 */
import java.io.*;
import java.util.*;

public class sea_mb_wa_2 {
    static void myAssert(String msg, boolean exp) {
        if (!exp) {
            throw new AssertionError(msg);
        }
    }

    static class MutablePoint implements Comparable<MutablePoint> {
        public int x, y;
        public final int f;

        public MutablePoint(int x, int y, int f) {
            this.x = x;
            this.y = y;
            this.f = f;
        }

        public void set(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public void move(int x, int y) {
            this.x += x;
            this.y += y;
        }

        public int compareTo(MutablePoint a) {
            return x == a.x ? y - a.y : x - a.x;
        }

        public String toString() {
            return "(" + x + "; " + y + ")@" + f;
        }
    }

    static class Fleet {
        final int index;
        final MutablePoint[] pts;
        final int t, dx, dy;

        int size() {
            return pts.length;
        }

        void move(int times) {
            int ddx = dx * times;
            int ddy = dy * times;
            for (int i = 0; i < pts.length; ++i) {
                pts[i].move(ddx, ddy);
            }
        }

        Fleet(int index, BufferedReader input) throws IOException {
            this.index = index;
            StringTokenizer firstLine = new StringTokenizer(input.readLine());
            int n = Integer.parseInt(firstLine.nextToken());
            t = Integer.parseInt(firstLine.nextToken());
            dx = Integer.parseInt(firstLine.nextToken());
            dy = Integer.parseInt(firstLine.nextToken());

            myAssert("Ship count is out of bounds", 1 <= n && n <= 10000);
            myAssert("t is out of bounds", 1 <= t && t <= 10);
            myAssert("dx is out of bounds", -10 <= dx && dx <= 10);
            myAssert("dy is out of bounds", -10 <= dy && dy <= 10);
            myAssert("Extra tokens in the first line of fleet description", !firstLine.hasMoreTokens());

            pts = new MutablePoint[n];
            for (int i = 0; i < n; ++i) {
                StringTokenizer st = new StringTokenizer(input.readLine());
                int x = Integer.parseInt(st.nextToken());
                int y = Integer.parseInt(st.nextToken());
                pts[i] = new MutablePoint(x, y, index);
                myAssert("x[i] is out of bounds", -1000000000 <= x && x <= 1000000000);
                myAssert("y[i] is out of bounds", -1000000000 <= y && y <= 1000000000);
                myAssert("Extra tokens in the ship description", !st.hasMoreTokens());
            }
        }
    }

    static class AnswerHolder {
        private long time = -1;

        public void updateAnswer(long ans) {
            if (ans < 0) {
                throw new AssertionError();
            }
            if (time == -1) {
                time = ans;
            } else {
                time = Math.min(time, ans);
            }
        }

        public long answer() {
            return time;
        }
    }

    static class Description {
        private final long vmul;
        private final int remX;
        private final int remY;

        public Description(int x, int y, int dx, int dy) {
            this.vmul = (long) (x) * dy - (long) (y) * dx;
            /**
             * Ошибка здесь.
             */
            this.remX = dx == 0 ? 0 : x % dx;
            this.remY = dy == 0 ? 0 : y % dy;
        }

        public int hashCode() {
            long x = vmul + 31 * (remX + 31 * remY);
            return (int) (x + (x >>> 32));
        }

        public boolean equals(Object o) {
            Description d = (Description)o;
            return d.vmul == vmul && d.remX == remX && d.remY == remY;
        }
    }

    private static int gcd(int a, int b) {
        while (a != 0) {
            int t = b % a;
            b = a;
            a = t;
        }
        return b;
    }

    private static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

    private static int solve(Fleet f, Fleet g, int adx, int ady) {
        int rv = Integer.MAX_VALUE;
        Map<Description, List<MutablePoint>> classifier = new HashMap<Description, List<MutablePoint>>();
        for (MutablePoint p : f.pts) {
            Description d = new Description(p.x, p.y, adx, ady);
            List<MutablePoint> list = classifier.get(d);
            if (list == null) {
                classifier.put(d, list = new ArrayList<MutablePoint>());
            }
            list.add(p);
        }
        for (MutablePoint p : g.pts) {
            Description d = new Description(p.x, p.y, adx, ady);
            List<MutablePoint> list = classifier.get(d);
            if (list == null) {
                classifier.put(d, list = new ArrayList<MutablePoint>());
            }
            list.add(p);
        }
        for (Map.Entry<Description, List<MutablePoint>> entry : classifier.entrySet()) {
            MutablePoint[] pts = entry.getValue().toArray(new MutablePoint[entry.getValue().size()]);
            Arrays.sort(pts);
            for (int i = 1; i < pts.length; ++i) {
                if (pts[i - 1].f == f.index && pts[i].f == g.index) {
                    if (Math.signum(pts[i].x - pts[i - 1].x) == Math.signum(adx) && Math.signum(pts[i].y - pts[i - 1].y) == Math.signum(ady)
                        ||
                        pts[i].x == pts[i - 1].x && pts[i].y == pts[i - 1].y) {
                        int rvx = adx == 0 ? 0 : (pts[i].x - pts[i - 1].x) / adx;
                        int rvy = ady == 0 ? 0 : (pts[i].y - pts[i - 1].y) / ady;
                        rv = Math.min(rv, Math.max(rvx, rvy));
                    }
                }
                if (pts[i - 1].f == g.index && pts[i].f == f.index) {
                    if (Math.signum(pts[i - 1].x - pts[i].x) == Math.signum(adx) && Math.signum(pts[i - 1].y - pts[i].y) == Math.signum(ady)
                        ||
                        pts[i].x == pts[i - 1].x && pts[i].y == pts[i - 1].y) {
                        int rvx = adx == 0 ? 0 : (pts[i - 1].x - pts[i].x) / adx;
                        int rvy = ady == 0 ? 0 : (pts[i - 1].y - pts[i].y) / ady;
                        rv = Math.min(rv, Math.max(rvx, rvy));
                    }
                }
            }
        }

        if (rv == Integer.MAX_VALUE) {
            return -1;
        } else {
            return rv;
        }
    }

    private static void solve(Fleet f, Fleet g, AnswerHolder ans) {
        int period = lcm(f.t, g.t);
        int fTimes = period / f.t;
        int gTimes = period / g.t;
        int gdx = gTimes * g.dx;
        int gdy = gTimes * g.dy;
        int adx = fTimes * f.dx - gTimes * g.dx;
        int ady = fTimes * f.dy - gTimes * g.dy;
        for (int t = 0; t < period; ++t) {
            boolean test = false;
            if (t % f.t == 0) {
                f.move(1);
                test = true;
            }
            if (t % g.t == 0) {
                g.move(1);
                test = true;
            }
            if (test) {
                int a = solve(f, g, adx, ady);
                if (a != -1) {
                    ans.updateAnswer(1 + t + (long)a * period);
                }
            }
        }
        f.move(-fTimes);
        g.move(-gTimes);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("sea.in"));
        int n = 2;
        Fleet[] fleets = new Fleet[n];
        for (int i = 0; i < n; ++i) {
            fleets[i] = new Fleet(i, in);
        }

        AnswerHolder ans = new AnswerHolder();

        for (int f1 = 0; f1 < n; ++f1) {
            for (int f2 = f1 + 1; f2 < n; ++f2) {
                solve(fleets[f1], fleets[f2], ans);
            }
        }

        PrintWriter out = new PrintWriter("sea.out");
        out.println(ans.answer());
        out.close();
    }
}
