#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <complex>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
// #include <tuple>
// #include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))


typedef long double D;
const D EPS = 1e-8,INF = 1e12;

template<typename T> int sig(T a,T b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
template<typename T> bool eq(T a,T b){ return sig(abs(a-b))==0;}
template<typename T> D norm(T a){ return a*a;}

typedef complex<D> P,Vec;
#define X real()
#define Y imag()

bool debug = false;


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

// a×b
D cross(const Vec& a,const Vec& b){
	return imag(conj(a)*b);
}
// a・b
D dot(const Vec& a,const Vec& b) {
	return real(conj(a)*b);
}
//射影ベクトル
Vec proj(Vec p,Vec b) {
	return b * dot(p,b) / norm(b);
}

//直線・線分
struct L : public vector<P> {
	L(const P &a, const P &b) {
	  	push_back(a); push_back(b);
	 }
};

//直線へ射影した時の点
P projection(const L &l, const P &p) {
	return l[0] + proj(p-l[0],l[1]-l[0]);
}

D distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}

struct C {
 	P o; D r;
 	C(const P &o,D r) : o(o), r(r) { }
};

vector<P> intersectionLC(L l,C c){
	D d = distanceLP(l,c.o);
	vector <P> res;
 	if(eq(d,c.r)){
		res.push_back(projection(l,c.o));
	}else if(sig(d,c.r)<0){
		P m = projection(l,c.o),u = (l[1]-l[0])/abs(l[1]-l[0]);
	 	D t = sqrt(c.r*c.r - d*d);
		res.push_back( m + t * u);res.push_back( m - t * u);
	}
	return res;
}

int ccw(const P& a,P b,P c){
	b -= a; c -= a;
	if (cross(b,c) > EPS)   return +1;      	// counter clockwise
	if (cross(b,c) < -EPS)   return -1;      	// clockwise
	if (dot(b,c) < 0)     return +2;        // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0; 								// a--c--b on line (or b==c)
}

vector<P> intersectionSC(L l,C c){
	vector<P> ps=intersectionLC(l,c),res;
	REP(i,ps.size()){
		if(ccw(ps[i],l[0],l[1])==+2 || ccw(ps[i],l[1],l[0])==+2){
			res.push_back(ps[i]);
		}
	}
	return res;
}

//浮動小数点modで非負の値のみかえす．
D pfmod(D v,D M=2*M_PI){
	return fmod(fmod(v,M)+M,M);
}

int main(){
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
		int m,n;cin >> m >> n;
		if(m==0 && n==0)break;

		vector<P> ps(m);
		REP(i,m){
			D x,y;cin >>x >> y;ps[i]=P(x,y); 
		}
		vector<P> qs(n);
		REP(i,n){
			D x,y;cin >>x >> y;qs[i]=P(x,y); 
		}
		P c;
		{
			D x,y;cin >>x >> y;c=P(x,y); 
		}

		D ma = 2 * M_PI;
		REP(i,m){
			C ic(c,abs(ps[i]-c));
			REP(j,n){
				L l(qs[j],qs[(j+1)%n]);
				vector<P> ip=intersectionSC(l,ic);
				REP(k,ip.size()){
					D a=pfmod(arg(ps[i]-c)-arg(ip[k]-c));
					ma=min(ma,a);
				}
			}
		}
		REP(j,n){
			C ic(c,abs(qs[j]-c));
			REP(i,m){
				L l(ps[i],ps[(i+1)%m]);
				vector<P> ip=intersectionSC(l,ic);
				REP(k,ip.size()){
					D a=pfmod(arg(ip[k]-c)-arg(qs[j]-c));
					ma=min(ma,a);
				}
			}
		}

		cout << ma * 360.0/(2*M_PI)<<endl;
	}


	return 0;
}