#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int gcd( int a, int b )
{
  return a == 0 ? b : gcd(b % a, a);
}

int main()
{
  freopen("sea.in", "r", stdin);
  freopen("sea.out", "w", stdout);
  
  int m[2], t[2], dx[2], dy[2];
  int *x[2], *y[2];
  for (int pl = 0; pl < 2; pl++)
  {
    scanf("%d%d%d%d", &m[pl], &t[pl], &dx[pl], &dy[pl]);
    x[pl] = new int[m[pl]], y[pl] = new int[m[pl]];
    for (int i = 0; i < m[pl]; i++)
      scanf("%d%d", &x[pl][i], &y[pl][i]);
  }
  unsigned int ans = (unsigned int)-1;
  int period = t[0] * t[1] / gcd(t[0], t[1]);
  int jx = dx[1] * period / t[1] - dx[0] * period / t[0], mx = abs(jx);
  int jy = dy[1] * period / t[1] - dy[0] * period / t[0], my = abs(jy);
  if (mx == 0)
    mx = (int)1.01e9;
  if (my == 0)
    my = (int)1.01e9;
  for (int start = 0; start < period; start++)
  {
    bool move = false;
    for (int pl = 0; pl < 2; pl++)
      if (start % t[pl] == 0)
      {
        for (int i = 0; i < m[pl]; i++)
          x[pl][i] += dx[pl], y[pl][i] += dy[pl];
        move = true;
      }
    if (!move)
      continue;
    vector <pair <pair <int, int>, pair <int, int> > > v;
    for (int i = 0; i < m[0]; i++)
    {
      int tx = (x[0][i] % mx + mx) % mx;
      int ty = (y[0][i] % my + my) % my;
      int rx = (x[0][i] - tx) / (jx == 0 ? 1 : jx);
      int ry = (y[0][i] - ty) / (jy == 0 ? 1 : jy);
      int ra = rx - ry, rb = rx + ry;
      if (jx == 0)
        ra = 0, rb = ry;
      else if (jy == 0)
        ra = 0, rb = rx;
      v.push_back(make_pair(make_pair(tx, ty), make_pair(ra, rb)));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < m[1]; i++)
    {
      int tx = (x[1][i] % mx + mx) % mx;
      int ty = (y[1][i] % my + my) % my;
      int rx = (x[1][i] - tx) / (jx == 0 ? 1 : jx);
      int ry = (y[1][i] - ty) / (jy == 0 ? 1 : jy);
      int ra = rx - ry, rb = rx + ry;
      if (jx == 0)
        ra = 0, rb = ry;
      else if (jy == 0)
        ra = 0, rb = rx;
      pair <pair <int, int>, pair <int, int> > val = make_pair(make_pair(tx, ty), make_pair(ra, rb));
      int mini = 0, maxi = v.size();
      while (mini < maxi)
      {
        int ave = (mini + maxi) / 2;
        if (v[ave] < val)
          mini = ave + 1;
        else
          maxi = ave;
      }
      if (mini < (int)v.size() && val.first == v[mini].first && val.second.first == v[mini].second.first)
      {
        int tt = v[mini].second.second - val.second.second;
        if (jx != 0 && jy != 0)
          tt /= 2;
        ans = min(ans, (unsigned int)(tt * period + start + 1));
      }
    }
  }

  printf("%d\n", (int)ans);

  for (int pl = 0; pl < 2; pl++)
    delete[] x[pl], delete[] y[pl];
  return 0;
}

