import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class snow_va_wa implements Runnable {
    public static void main(String[] args) {
        new Thread(new snow_va_wa()).run();
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }

        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public double eps = 0.001;

 public class Point {
        long x, y;

        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public double dist(double px, double py) {
            return Math.sqrt((x - px) * (x - px) + (y - py) * (y - py));
        }

        public long dist(Point p) {
            return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y);
        }
    }

    public int getHalfPlane(long x, long y) {
        return y == 0 ? (x >= 0 ? 0 : 1) : (y > 0 ? 0 : 1);
    }

    public int compare(Vector a, Vector b) {
        int hp = getHalfPlane(a.x, a.y);
        int thp = getHalfPlane(b.x, b.y);

        if (hp == thp) {
            return (int) Math.signum(b.x * a.y - a.x * b.y);
        } else {
            return hp - thp;
        }
    }

    public class Vector implements Comparable<Vector> {
        long x, y;
        int id;

        public Vector(long x, long y, int id) {
            this.x = x;
            this.y = y;
            this.id = id;
        }

        public int compareTo(Vector v) {
            return compare(this, v);
        }

        public Vector negate() {
            return new Vector(-x, -y, id);
        }
    }

    public int nearest(Vector[] v, Vector x) {
        int l = -1;
        int r = v.length;
        while (l < r - 1) {
            int m = (l + r) / 2;
            if (compare(v[m], x) > 0) {
                r = m;
            } else {
                l = m;
            }
        }
        return v[r % v.length].id;
    }

    public class Line {
        long A, B, C;
        Point x;

        public Line(Point x, Point y) {
            this.A = x.y - y.y;
            this.B = y.x - x.x;
            this.C = -A * x.x - B * x.y;
            this.x = x;
        }

        public double intersect(Point a, Point b) {
            long A = a.y - b.y;
            long B = b.x - a.x;
            long C = -A * a.x - B * a.y;

            if (A * this.B == B * this.A) {
                return Double.NEGATIVE_INFINITY;
            }

            double x = -(C * this.B - this.C * B) / (A * this.B - this.A * B);
            double y = (C * this.A - this.C * A) / (A * this.B - this.A * B);

            if (Math.min(a.x, b.x) - eps <= x && x <= Math.max(a.x, b.x) + eps) {
                if (Math.min(a.y, b.y) - eps <= y && y <= Math.max(a.y, b.y) + eps) {
                    return this.x.dist(x, y) * Math.signum(x - this.x.x);
                }
            }
            return Double.NEGATIVE_INFINITY;
        }

        public double intersection(Point[] p, int l, int r, int dx, int dy) {
            int le = (int) Math.signum(this.evaluate(p[l % p.length], dx, dy));
            int re = (int) Math.signum(this.evaluate(p[r % p.length], dx, dy));
            if (le == re || le == 0 || re == 0) {
                return Double.NEGATIVE_INFINITY;
            }

            while (l < r - 1) {
                int m = (l + r) / 2;
                if ((int) Math.signum(this.evaluate(p[m % p.length], dx, dy)) == le) {
                    l = m;
                } else {
                    r = m;
                }
            }
            return intersect(p[l % p.length], p[(l + 1) % p.length]);
        }

        public long evaluate(Point p, int dx, int dy) {
            return A * (p.x + dx) + B * (p.y + dy) + C;
        }

        public Vector getVector() {
            return new Vector(-B, A, -1);
        }
    }

    public class Event implements Comparable<Event> {
        double x;
        int f;

        public Event(double x, int f) {
            this.x = x;
            this.f = f;
        }

        public int compareTo(Event e) {
            return Double.compare(x, e.x);
        }
    }

    public void solve() throws IOException {
        Line l = new Line(new Point(nextInt(), nextInt()), new Point(nextInt(), nextInt()));
        int n = nextInt();
        Point[] p = new Point[n];
        for (int i = 0; i < n; i++) {
            p[i] = new Point(nextInt(), nextInt());
        }

        Vector[] v = new Vector[n];
        for (int i = 0; i < n; i++) {
            v[i] = new Vector(p[(i + 1) % n].x - p[i].x, p[(i + 1) % n].y - p[i].y, i);
        }

        Arrays.sort(v);

        int up = nearest(v, l.getVector());
        int down = nearest(v, l.getVector().negate());

        int m = nextInt();

        int len = 0;
        Event[] e = new Event[2 * m];

        int dx = 0;
        int dy = 0;

        for (int i = 0; i < m; i++) {
            int x = nextInt();
            int y = nextInt();

            double left = Double.MAX_VALUE;
            double right = Double.NEGATIVE_INFINITY;

            int u = nearest(v, new Vector(x, y, i));
            int d = nearest(v, new Vector(x, y, i).negate());
            if (u > d) {
                int q = u;
                u = d;
                d = q;
            }

            double t = l.intersect(new Point(p[u].x + dx, p[u].y + dy), new Point(p[u].x + dx + x, p[u].y + dy + y));
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }

            t = l.intersect(new Point(p[d].x + dx, p[d].y + dy), new Point(p[d].x + dx + x, p[d].y + dy + y));
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }


            /* Intersection of the first part */
            t = l.intersection(p, up, down, dx, dy);
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }

            t = l.intersection(p, down, up + p.length, dx, dy);
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }

            /* Intersection */
            t = l.intersection(p, up, down, dx + x, dy + y);
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }

            t = l.intersection(p, down, up + p.length, dx + x, dy + y);
            if (t != Double.NEGATIVE_INFINITY) {
                left = Math.min(t, left);
                right = Math.max(t, right);
            }

            if (right != Double.NEGATIVE_INFINITY) {
                e[len++] = new Event(left, 1);
                e[len++] = new Event(right, -1);
            }

            dx += x;
            dy += y;
        }

        e = Arrays.copyOf(e, len);

        Arrays.sort(e);

        double ans = 0;
        int now = 0;
        double prev = 0;
        for (Event event : e) {
            if (now > 0) {
                ans += event.x - prev;
            }
            prev = event.x;
            now += event.f;
        }

        out.println(ans);
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader("snow.in"));
            out = new PrintWriter("snow.out");

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
