#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

P unit(const P &p){
    return p/abs(p);
}

bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}

P projection(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]);
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}


VP crosspointCL(const C &c, const L &l){
    VP ret;
    P mid = projection(l, c.p);
    double d = distanceLP(l, c.p);
    if(EQ(d, c.r)){
        ret.push_back(mid);
    }else if(d < c.r){
        double len = sqrt(c.r*c.r -d*d);
        ret.push_back(mid +len*unit(l[1]-l[0]));
        ret.push_back(mid -len*unit(l[1]-l[0]));
    }
    return ret;
}
VP crosspointCS(const C &c, const L &s){
    VP ret;
    VP cp = crosspointCL(c,s);
    for(int i=0; i<(int)cp.size(); i++){
        if(intersectSP(s, cp[i])){
            ret.push_back(cp[i]);
        }
    }
    return ret;
}

double getangle360(const P &p, const P &a, const P &b){
    P proj = projection(L(p,a), b);
    int sign= (dot(a-p, b-p)>0)? 1: -1;
    if(ccw(p,a,b)!=-1){
        return acos(sign*abs(proj-p)/abs(b-p));
    }else{
        return 2*PI - acos(sign*abs(proj-p)/abs(b-p));
    }
}

int main(){
    while(1){
        int m,n;
        cin >> m >> n;
        if(m == 0) break;

        VP p(m), q(n);
        for(int i=0; i<m; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            q[i] = P(x, y);
        }
        double cx,cy;
        cin >> cx >> cy;
        P c(cx, cy);

        double ans = 2*PI;
        //すべての辺同士の組み合わせ
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                L ei(p[i], p[(i+1)%m]), ej(q[j], q[(j+1)%n]);
                for(int d=0; d<2; d++){
                    C ci(c, abs(ei[d] -c)), cj(c, abs(ej[d] -c));
                    VP cpi = crosspointCS(ci, ej);
                    for(P p: cpi){
                        ans = min(ans, getangle360(c, p, ei[d]));
                    }
                    VP cpj = crosspointCS(cj, ei);
                    for(P p: cpj){
                        ans = min(ans, getangle360(c, ej[d], p));
                    }
                }
            }
        }        


        cout << fixed << setprecision(10);
        cout << ans*180/PI << endl;
    }
    return 0;
}


Measured memory_bytes: 3608