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

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

    static class MutablePoint {
        public int x, y;

        public MutablePoint() {}
        public MutablePoint(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public void set(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public boolean equals(Object o) {
            MutablePoint m = (MutablePoint) o;
            return x == m.x && y == m.y;
        }
        public int hashCode() {
            return x * 31 + 239 * y;
        }
    }

    static class Fleet {
        final int[] x, y;
        final int t, dx, dy;

        int size() {
            return x.length;
        }

        Fleet(BufferedReader input) throws IOException {
            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());

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

    public static void main(String[] args) throws IOException {
        long t0 = System.currentTimeMillis();

        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(in);
        }

        MutablePoint[][] pts = new MutablePoint[n][];
        for (int i = 0; i < pts.length; ++i) {
            pts[i] = new MutablePoint[fleets[i].size()];
            for (int j = 0; j < pts[i].length; ++j) {
                pts[i][j] = new MutablePoint();
            }
        }

        int answer = -1;
        for (int time = 1; time % 10 != 0 || (System.currentTimeMillis() - t0 < 5900); ++time) {
            for (int i = 0; i < fleets.length; ++i) {
                Fleet f = fleets[i];
                MutablePoint[] pp = pts[i];
                if ((time - 1) % f.t == 0) {
                    for (int j = f.size() - 1; j >= 0; --j) {
                        f.x[j] += f.dx;
                        f.y[j] += f.dy;
                    }
                }
                for (int j = f.size() - 1; j >= 0; --j) {
                    pp[j].set(f.x[j], f.y[j]);
                }
            }
            Set<MutablePoint> set = new HashSet<MutablePoint>();
            for (MutablePoint[] mp : pts) {
                for (MutablePoint p : mp) {
                    set.add(p);
                }
            }
            if (set.size() < sum) {
                answer = time;
                break;
            }
        }

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