import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

immutable real EPS = 1e-7;

struct Point {
    real x, y;
    Point opBinary(string op)(in Point p) const if (op == "+" || op == "-") {
        return Point(mixin("x" ~ op ~ "p.x"), mixin("y" ~ op ~ "p.y"));
    }
    Point opBinary(string op)(real k) const if (op == "*" || op == "/") {
        return Point(mixin("x" ~ op ~ "k"), mixin("y" ~ op ~ "k"));
    }
};
real dot(in Point a, in Point b) { return a.x * b.x + a.y * b.y; }
real cross(in Point a, in Point b) { return a.x * b.y - a.y * b.x; }
real norm(in Point a) { return sqrt(dot(a, a)); }
Point rot90(in Point p) { return Point(-p.y, p.x); }
real angle(in Point a) { return atan2(a.y, a.x); }

int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;                                          
    if (cross(b, c) > EPS) return +1;      // a,b,c????????????????¨???¨???
    if (cross(b, c) < -EPS) return -1;     // a,b,c?????????????¨???¨???                       
    if (dot(b, c) < 0) return +2;          // c--a--b ??´???                       
    if (norm(b) < norm(c)) return -2;      // a--b--c ??´???                       
    return 0;                              // a--c--b ??´???
}

struct Line {
    Point a, b;
};
bool contains(in Line l, in Point p) { return ccw(l.a, l.b, p) % 2 == 0; }
bool parallel(in Line s, in Line t) { return abs(cross(s.b - s.a, t.b - t.a)) < EPS; }
bool orthogonal(in Line s, in Line t) { return abs(dot(s.b - s.a, t.b - t.a)) < EPS; }
bool equals(in Line s, in Line t) { return parallel(s, t) && contains(s, t.a); }
Point crosspoint(in Line s, in Line t) {
    real d = cross(t.b - t.a, s.b - s.a);
    assert(abs(d) >= EPS);
    return s.a + (s.b - s.a) * cross(t.b - t.a, t.b - s.a) / d;
}

Point projection(in Line l, in Point p) {
    Point u = (p - l.a), v = (l.b - l.a);
    return l.a + (v / norm(v)) * (dot(u, v) / norm(v));
}
Point reflection(in Line l, in Point p) {
    Point h = projection(l, p);
    return p + (h - p) * 2;
}

struct Segment {
    Point a, b;
};
bool intersects(in Segment s, in Segment t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool contains(in Segment s, in Point p) {
    return ccw(s.a, s.b, p) == 0;
}
real dist(in Segment s, in Point p) {
    Point q = projection(Line(s.a, s.b), p);
    auto t = Segment(p, q);
    if (intersects(s, t)) return norm(t.b - t.a);
    return min(norm(s.a - p), norm(s.b - p));
}
real dist(in Segment s, in Segment t) {
    if (intersects(s, t)) return 0;
    return min( min(dist(s, t.a), dist(s, t.b)),
                min(dist(t, s.a), dist(t, s.b)) );
}

struct Circle {
    Point p;
    real r;
};
bool contains(in Circle c, in Point p) { return norm(c.p - p) < c.r + EPS; }
bool contains(in Circle a, in Circle b) { return b.r + norm(a.p - b.p) < a.r + EPS; }
bool intersects(in Circle a, in Circle b) {
    if (contains(a, b) || contains(b, a)) return false;
    return norm(a.p - b.p) < a.r + b.r + EPS;
}
Point[] crosspoints(in Circle c, in Line l) {
    Point x = l.projection(c.p);
    real d = norm(x - c.p);
    if (d > c.r + EPS) {
        return []; // ????????????
    }
    if (abs(c.r - d) <= EPS) return [x]; // x??§??\??????
    if (d <= EPS) { // l???c?????´??????????????´???
        Point v = (norm(l.a - c.p) < EPS ? (l.b - c.p) / norm(l.b - c.p) : (l.a - c.p) / norm(l.a - c.p));
        return [c.p - v * c.r, c.p + v * c.r];
    }
    real t = sqrt(c.r^^2 - d^^2);
    Point v = (norm(l.a - x) < EPS ? (l.b - x) / norm(l.b - x) : (l.a - x) / norm(l.a - x));
    return [x - v * t, x + v * t];
}
Point[] crosspoints(in Circle c, in Segment s) {
    auto ps = crosspoints(c, Line(s.a, s.b));
    Point[] ret;
    foreach (p; ps) {
        if (s.contains(p)) ret ~= p;
    }
    return ret;
}

void main() {
    while (true) {
        int M, N; readf("%d %d\n", &M, &N);
        if (M == 0 && N == 0) break;
        Point[] E = new Point[M];
        auto buf = readln.stripRight.chomp.split(" ").map!(to!real).array;
        foreach (i; 0 .. M) {
            E[i] = Point(buf[2 * i], buf[2 * i + 1]);
        }
        Point[] P = new Point[N];
        buf = readln.stripRight.chomp.split(" ").map!(to!real).array;
        foreach (i; 0 .. N) {
            P[i] = Point(buf[2 * i], buf[2 * i + 1]);
        }
        Point C;
        readf("%s %s\n", &C.x, &C.y);

        real ans = 2 * PI;
        // rotate patient
        Segment[] ss;
        foreach (i; 0 .. M) {
            ss ~= Segment(E[i], E[(i + 1) % M]);
        }
        foreach (p; P) {
            auto c = Circle(C, norm(p - C));
            if (dot(p - C, p - C) <= EPS) continue; // ?????¢????????????p. ???????????????????????¨?????????????????¨?????????
            foreach (s; ss) {
                auto cps = c.crosspoints(s);
                //log([c], [s], " cps: ", cps);
                foreach (q; cps) {
                    real theta = acos( (dot(p - C, p - C) + dot(q - C, q - C) - dot(p - q, p - q)) / (2.0 * norm(p - C) * norm(q - C)) );
                    if (ccw(C, p, q) != 1) {
                        theta = 2 * PI - theta;
                    }
                    ans = min(ans, theta);
                }
            }
        }

        Segment[] ts;
        foreach (i; 0 .. N) {
            ts ~= Segment(P[i], P[(i + 1) % N]);
        }
        foreach (p; E) {
            auto c = Circle(C, norm(p - C));
            if (dot(p - C, p - C) <= EPS) continue;
            foreach (s; ts) {
                auto cps = c.crosspoints(s);
                //log([c], [s], " cps: ", cps);
                foreach (q; cps) {
                    real theta = acos( (dot(p - C, p - C) + dot(q - C, q - C) - dot(p - q, p - q)) / (2.0 * norm(p - C) * norm(q - C)) );
                    if (ccw(C, p, q) != -1) {
                        theta = 2 * PI - theta;
                    }
                    //log([p, q], " ", theta);
                    ans = min(ans, theta);
                }
            }
        }

        writefln("%.12f", ans * 180 / PI);
    }
}

Measured memory_bytes: 3316