HCII, the health committee for interstellar intelligence, aims to take care of the health of every interstellar intelligence.

Staff of HCII uses a special equipment for health checks of patients. This equipment looks like a polygon-shaped room with plenty of instruments. The staff puts a patient into the equipment, then the equipment rotates clockwise to diagnose the patient from various angles. It fits many species without considering the variety of shapes, but not suitable for big patients. Furthermore, even if it fits the patient, it can hit the patient during rotation.

<image>

Figure 1: The Equipment used by HCII

The interior shape of the equipment is a polygon with M vertices, and the shape of patients is a convex polygon with N vertices. Your job is to calculate how much you can rotate the equipment clockwise without touching the patient, and output the angle in degrees.



Input

The input consists of multiple data sets, followed by a line containing “0 0”. Each data set is given as follows:


M N
px1 py1 px2 py2 ... pxM pyM
qx1 qy1 qx2 qy2 ... qxN qyN
cx cy


The first line contains two integers M and N (3 ≤ M, N ≤ 10). The second line contains 2M integers, where (pxj , pyj ) are the coordinates of the j-th vertex of the equipment. The third line contains 2N integers, where (qxj , qyj ) are the coordinates of the j-th vertex of the patient. The fourth line contains two integers cx and cy, which indicate the coordinates of the center of rotation.

All the coordinates are between -1000 and 1000, inclusive. The vertices of each polygon are given in counterclockwise order.

At the initial state, the patient is inside the equipment, and they don’t intersect each other. You may assume that the equipment doesn’t approach patients closer than 10-6 without hitting patients, and that the equipment gets the patient to stick out by the length greater than 10-6 whenever the equipment keeps its rotation after hitting the patient.

Output

For each data set, print the angle in degrees in a line. Each angle should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-7 .

If the equipment never hit the patient during the rotation, print 360 as the angle.

Example

Input

5 4
0 0 20 0 20 10 0 10 1 5
10 3 12 5 10 7 8 5
10 5
4 3
0 0 10 0 10 5 0 5
3 1 6 1 5 4
0 0
5 3
0 0 10 0 10 10 0 10 3 5
1 1 4 1 4 6
0 0
0 0


Output

360.0000000
12.6803835
3.3722867
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef complex<double> Point;
const double EPS = 1e-6;
double dot(Point a, Point b){
    return real(conj(a) * b);
}
double cross(Point a, Point b){
    return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    double len = abs(b) * abs(c); // 速さが気になるときは1にする
    if (cross(b, c) > +len * EPS)   return +1; // 反時計回り
    if (cross(b, c) < -len * EPS)   return -1; // 時計回り
    if (dot(b, c) < 0)     return +2; // c--a--b の順番で一直線上
    if (norm(b) < norm(c)) return -2; // a--b--c の順番で一直線上
    return 0;                         // 点が線分ab上にある
}

double angle(Point a, Point b){
    double res = arg(conj(a) * b);
    if(res < 0) res += 2 * M_PI;
    return res;
}

struct Line : public vector<Point> {
    Line(const Point& a, const Point& b) {
        push_back(a); push_back(b);
    }
    Point vector() const {
        return back() - front();
    }
};
struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(Point p, double r) : p(p), r(r) { }
};
bool intersectSP(Line s, Point p) {
    return ccw(s[0], s[1], p) == 0;
}

Point projection(Line l, Point p){
    double t = dot(p - l[0], l.vector()) / norm(l.vector());
    return l[0] + t * l.vector();
}

vector<Point> crosspointLC(const Line &l, const Circle &c) {
    vector<Point> res;
    Point center = projection(l, c.p);
    double d = abs(center - c.p);
    double tt = c.r * c.r - d * d;
    if(tt < 0 && tt > -EPS) tt = 0;
    if(tt < 0) return res;
    double t = sqrt(tt);
    Point vect = l.vector();
    vect /= abs(vect);
    res.push_back(center - vect * t);
    if (t > EPS) {
        res.push_back(center + vect * t);
    }
    return res;
}

vector<Point> crosspointSC(const Line &s, const Circle &c) {
    vector<Point> ret;
    vector<Point> nret = crosspointLC(s, c);
    for (int i = 0; i < nret.size(); i++) {
        if (intersectSP(s, nret[i])) ret.push_back(nret[i]);
    }
    return ret;
}

int main(){
    int M, N;
    while(cin >> M >> N && M){
        vector<Point> ps(M);
        vector<Point> qs(N);
        REP(i, M){
            double x, y;
            cin >> x >> y;
            ps[i] = Point(x, y);
        }
        REP(i, N){
            double x, y;
            cin >> x >> y;
            qs[i] = Point(x, y);
        }
        double cx, cy;
        cin >> cx >> cy;
        Point cp(cx, cy);
        double ans = 2.0 * M_PI;
        for(int i = 0; i < N; i++){
            Circle C(cp, abs(qs[i] - cp)); // qs[i]の軌道
            for(int j = 0; j < M; j++){
                Line s(ps[j], ps[(j == M - 1 ? 0 : j + 1)]);
                vector<Point> crosspv = crosspointSC(s, C);
                for(Point crossp : crosspv){
                    //cout << "Circle : " << C.p << " " << C.r << " cross with " << s[0] << " " << s[1] << " at " << crossp << endl;
                    ///cout << "angle : " << angle(qs[i] - cp, crossp - cp) << endl;
                    ans = min(ans, angle(qs[i] - cp, crossp - cp));
                }
            }
        }
        for(int i = 0; i < M; i++){
            Circle C(cp, abs(ps[i] - cp)); // ps[i]の軌道
            for(int j = 0; j < N; j++){
                Line s(qs[j], qs[(j == N - 1 ? 0 : j + 1)]);
                vector<Point> crosspv = crosspointSC(s, C);
                for(Point crossp : crosspv){
                    //cout << "Circle : " << C.p << " " << C.r << " cross with " << s[0] << " " << s[1] << " at " << crossp << endl;
                    //cout << "angle : " << angle(crossp - cp, ps[i] - cp) << endl;
                    ans = min(ans, angle(crossp - cp, ps[i] - cp));
                }
            }
        }
        printf("%.7f\n", ans / M_PI * 180.0);
    }
    return 0;
}