Problem: 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

Solution (in CPP):

Solution:
#include <complex>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};

typedef double R;
const R eps = 1e-8;
const R inf = 1e12;
const R pi = acos(-1);
typedef complex<R> P;
namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T> v){
        for(auto const& p : v) os << p << ",";
        return os;
    }
}
R cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}
R dot(const P& a, const P& b) {
    return real(conj(a)*b);
}
struct L : public vector<P> {
    // A to B
    L(const P &A, const P &B) {
        push_back(A); push_back(B);
    }
    // ax+by+c=0
    L(R a, R b, R c){
        if(fabs(a) < eps) *this = L(P(0,-c/b),P(1,-c/b));
        else if(fabs(b) < eps) *this = L(P(-c/a,0),P(-c/a,1));
        else *this = L(P(-c/a,0), P(0,-c/b));
    }
};
typedef vector<P> G;
struct C {
    P p; R r;
    C(const P &p, R r) : p(p), r(r) { }
    C(){}
};

// CCW
enum { CCW = +1, CW = -1, CAB = +2, ABC = -2, SAMEPOINT = 0 };
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return CCW; // a->b->c 反時計回り
    if (cross(b, c) < 0)   return  CW; // a->b->c 時計回り
    if (dot(b, c) < 0)     return CAB; // c--a--b 直線上
    if (norm(b) < norm(c)) return ABC; // a--b--c 直線上
    return SAMEPOINT; // 2点以上が重なっている
}

bool colSP(const L &s, const P &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < eps; // triangle inequality
}

bool colCP(const C &c, const P &p) {
    // 境界または内部
    return abs(c.p - p) <= c.r + eps;
}

int colCC(const C& c1, const C& c2){
    double d = abs(c1.p - c2.p), r1 = c1.r, r2 = c2.r;
    if(abs(d - r1 - r2) < eps) return  1; // 接する
    if(d > r1 + r2)       return  0; // 共通部分を持たない
    if(d < r1 - r2)       return +3; // c1 が c2 の中にある
    if(d < r2 - r1)       return -3; // c2 が c1 の中にある
    return 2; // 2つの交点を持つ
}

// 射影
P projLP(const L &l, const P &p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
L projLL(const L& l, const L& m) {
    return L(projLP(l,m[0]), projLP(l,m[1]));
}

// 反射
P reflLP(const L &l, const P &p) {
    return p + 2. * (projLP(l, p) - p);
}
L reflLL(const L& l, const L& m) {
    return L(reflLP(l,m[0]), reflLP(l,m[1]));
}

// 距離
R distLP(const L &l, const P &p) {
    return abs(p - projLP(l, p));
}

// Verify : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1183
vector<P> intCL(const C& c, const L& l){
    R d = distLP(l,c.p); // 中心と直線の距離
    if(fabs(d-c.r) < eps) return { projLP(l, c.p) }; // 触れている
    if(d > c.r) return {}; // 離れている
    P h = projLP(l, c.p);
    P u = sqrt(c.r*c.r - d*d) * (l[0]-l[1]) / abs(l[0]-l[1]);
    return {h+u, h-u};
}

vector<P> intCS(const C& c, const L& s){
    vector<P> cs = intCL(c,s), res;
    for(const P& p : cs) {
        if(colSP(s,p)) res.push_back(p);
    }
    return res;
}

// 角ABCの大きさを[0,Pi]で求める
R arg(P a, P b, P c) {
    R th = arg((a - b) / (c - b));
    return th > 0 ? th : th+2*pi;
}

int M,N;
G out,in;
P c;
R solve(){
    R ans = pi*2;
    rep(k,2){
        rep(i,out.size()-1)rep(j,in.size()-1){
            C cir(c,abs(c-in[j]));
            if(cir.r < eps) continue;
            L seg(out[i],out[i+1]);
            vector<P> cps = intCS(cir, seg);
            for(auto cp : cps){
                double th;
                if(k==1)th = arg(in[j], cir.p, cp);
                if(k==0)th = arg(cp,    cir.p, in[j]);
                // dump(th/pi*180);
                ans = min(ans,th);
            }
        }
        swap(in,out);
    }
    return ans*180/pi;
}

int main(){
    while(~scanf("%d%d",&M,&N) && M){
        out.resize(M+1);
        in.resize(N+1);
        rep(i,M){
            int x,y; scanf("%d%d",&x,&y);
            out[i] = P(x,y);
        }
        rep(i,N){
            int x,y; scanf("%d%d",&x,&y);
            in[i] = P(x,y);
        }
        out.back() = out.front();
        in.back() = in.front();
        int x,y; scanf("%d%d",&x,&y);
        c = P(x,y);
        printf("%.10lf\n",solve());
    }
}