#include<algorithm>
#include<complex>
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
template<class T> T at(vector<T> v, int i) {return v[i % v.size()];}

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return norm(a - b) < EPS;}

// テヲツッツ氾ィツシツεゥツ鳴「テヲツ閉ー
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
  bool operator<(L a, L b) {return !near(a.a, b.a) ? a.a < b.a : a.b < b.b;}
}

D sr(D a) {return sqrt(max(a, (D)0));}

// テ・ツ??ァツゥツ?
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// テ・ツ、ツ姪ァツゥツ?
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// テァツキツ堙・ツ按?」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォ
P vec(L a) {return a.b - a.a;}

// テァツキツ堙・ツ按?bテ」ツ?ォテ・ツッツセテ」ツ?凖」ツつ凝ァツつケcテ」ツ?ョテ、ツスツ催ァツスツョ
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(P a, P b, P c) {
  if (a == c || b == c) return ON;
  int s = sig(det(b - a, c - a));
  if (s) return s > 0 ? LEFT : RIGHT;
  return (a < b) == (b < c) ? FRONT : (c < a) == (a < b) ? BACK : ON;
}

// テヲツ慊嘉・ツ青妥ィツァツ津・ツコツヲ
D arg(P base, P a, P b) {
  D ang = arg((b - base) / (a - base));
  return ang > 0 ? ang : ang + 2 * PI;
}
L sortBase;
bool lessArg(P a, P b) {
  D ang1 = arg(sortBase.a, sortBase.b, a);
  D ang2 = arg(sortBase.a, sortBase.b, b);
  return sig(ang1, ang2) ? ang1 < ang2 : norm(a) > norm(b);
}

// テ・ツーツ?・ツスツア
P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}
P refl(L l, P p) {return perp(l, p) * (D)2 - p;}

// テ、ツコツ、テ・ツキツョテ・ツ按、テ・ツョツ?
bool eqL(L a, L b) {return !sig(det(vec(a), vec(b))) && !sig(det(vec(a), b.a - a.a));}
bool iLL(L a, L b) {return sig(det(vec(a), vec(b))) || !sig(det(vec(a), b.a - a.a));}
bool iLLs(L a, L b) {return sig(det(vec(a), vec(b)));}
bool iLS(L a, L b) {return sig(det(vec(a), b.a - a.a)) * sig(det(vec(a), b.b - a.a)) <= 0;}
bool iLSs(L a, L b) {return sig(det(vec(a), b.a - a.a)) * sig(det(vec(a), b.b - a.a)) < 0;}
bool iSS(L a, L b) {
  int cwa = ccw(a.a, a.b, b.a) | ccw(a.a, a.b, b.b);
  int cwb = ccw(b.a, b.b, a.a) | ccw(b.a, b.b, a.b);
  return ((cwa | cwb) & ON) || ((cwa & cwb) == (LEFT | RIGHT));
}
bool iSSs(L a, L b) {
  int cwa = ccw(a.a, a.b, b.a) | ccw(a.a, a.b, b.b);
  int cwb = ccw(b.a, b.b, a.a) | ccw(b.a, b.b, a.b);
  return (cwa & cwb) == (LEFT | RIGHT);
}

// テ、ツコツ、テァツつケ
P pLL(L a, L b) {return a.a + vec(a) * (det(vec(b), b.a - a.a) / det(vec(b), vec(a)));}

// ティツキツ敕ゥツ崢「
D dLP(L l, P p) {return abs(det(vec(l), p - l.a)) / abs(vec(l));}
D dSP(L s, P p) {
  if (dot(vec(s), p - s.a) < 0) return abs(p - s.a);
  if (dot(vec(s), p - s.b) > 0) return abs(p - s.b);
  return dLP(s, p);
}
D dLL(L a, L b) {return iLL(a, b) ? 0 : dLP(a, b.a);}
D dLS(L a, L b) {return iLS(a, b) ? 0 : min(dLP(a, b.a), dLP(a, b.b));}
D dSS(L a, L b) {return iSS(a, b) ? 0 : min(min(dSP(a, b.a), dSP(a, b.b)), min(dSP(b, a.a), dSP(b, a.b)));}

// テ・ツ??
struct C{P c; D r;};

// 2テ・ツ??」ツ?ョテ、ツスツ催ァツスツョテゥツ鳴「テ、ツソツ?
enum RELATION{SAME = 1, CONTAIN = 2, OVER = 4, NO_CROSS = 8, ONE_CROSS = 16, ONE_CONTAIN_CROSS = 32, ONE_OVER_CROSS = 64, TWO_CROSS = 128};
int cRel(C c1, C c2) {
  D d = abs(c1.c - c2.c);
  if (near(c1.c, c2.c) && !sig(c1.r, c2.r)) return SAME;
  if (sig(d, c1.r - c2.r) < 0) return OVER;
  if (sig(d, c2.r - c1.r) < 0) return CONTAIN;
  if (!sig(d, c1.r - c2.r)) return ONE_OVER_CROSS;
  if (!sig(d, c2.r - c1.r)) return ONE_CONTAIN_CROSS;
  if (!sig(d, c1.r + c2.r)) return ONE_CROSS;
  if (sig(d, c1.r + c2.r) > 0) return NO_CROSS;
  return TWO_CROSS;
}

// テ、ツコツ、テ・ツキツョテ・ツ按、テ・ツョツ?
bool iCP(C c, P p) {return sig(abs(p - c.c), c.r) <= 0;}
bool iCL(C c, L l) {return sig(c.r, dLP(l, c.c)) >= 0;}
bool iCS(C c, L s) {return sig(c.r, dSP(s, c.c)) >= 0;}
bool iCSc(C c, L s) {return iCS(c, s) && sig(c.r, max(abs(s.a - c.c), abs(s.b - c.c))) >= 0;}
bool iCC(C a, C b) {return sig(abs(a.c - b.c), a.r + b.r) <= 0;}
bool iCCc(C a, C b) {return iCC(a, b) && sig(abs(a.c - b.c), abs(a.r - b.r)) >= 0;}

// テ、ツコツ、テァツつケ
pair<P, P> pCC(C a, C b) {
  D x = (norm(a.c - b.c) + a.r * a.r - b.r * b.r) / (2 * abs(a.c - b.c));
  P e = (b.c - a.c) / abs(b.c - a.c);
  P y = e * P(0, sr(a.r * a.r - x * x));
  return make_pair(a.c + e * x - y, a.c + e * x + y);
}
pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

// ティツァツ津」ツ?ョテ・ツ??・ツ、ツ姪・ツ按、テ・ツョツ?ティツァツ誕bテ」ツ?ョテ・ツ??ゥツδィテ」ツ?ォテ」ツ?づ」ツつ古」ツ?ーテヲツュツ」テ」ツ??ィツセツコテ、ツクツ甘」ツ?ッ0テ」ツ??・ツ、ツ姪ゥツδィテ」ツ?ッティツイツ?
int sAP(P a, P b, P c) {return sig(det(a, c)) - sig(det(b, c)) - sig(det(a, b));}

// テ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョテゥツ敖「テァツゥツ?
D aPol(Pol vp) {
  D ret = 0;
  rep (i, vp.size()) ret += det(vp[i], at(vp, i + 1));
  return ret / 2;
}

// テ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョテ・ツ??・ツ、ツ姪・ツ按、テ・ツョツ?テ・ツ??ゥツδィ:1テ」ツ??・ツ堕ィテ、ツクツ?0テ」ツ??・ツ、ツ姪ゥツδィ:-1
int sGP(Pol pol, P p) {
  int side = -1;
  rep (i, pol.size()) {
    P p0 = pol[i] - p, p1 = at(pol, i + 1) - p;
    if (ccw(p0, p1, 0) == ON) return 0;
    if (p0.Y > p1.Y) swap(p0, p1);
    if (sig(p0.Y) <= 0 && 0 < sig(p1.Y) && sig(det(p0, p1)) > 0) side *= -1;
  }
  return side;
}

// テ・ツ?クテ・ツ個?
Pol convexHull(Pol p) {
  int m = -1, n = p.size();
  if (n < 3) return p;
  vector<P> q(n * 2);
  sort(p.begin(), p.end());
  for (int i = 0; i < n; q[++m] = p[i++])
    for (; m > 0 && ccw(q[m - 1], q[m], p[i]) != LEFT; --m);
  for (int i = n - 2, r = m; i >= 0; q[++m] = p[i--])
    for (; m > r && ccw(q[m - 1], q[m], p[i]) != LEFT; --m);
  q.resize(m);
  return q;
}

// テ・ツ?クテ・ツ個?」ツつォテ」ツδε」ツδ?
Pol convexCut(Pol p, L l) {
  vector<P> q;
  rep (i, p.size()) {
    if (ccw(l.a, l.b, p[i]) != RIGHT) q.push_back(p[i]);
    L s = {p[i], at(p, i + 1)};
    if (iLSs(l, s)) q.push_back(pLL(l, s));
  }
  return q;
}

// テァツキツ堙・ツ按?」ツつ津」ツδ榲」ツδシテ」ツつクテ」ツ?凖」ツつ?
vector<L> merge(vector<L> s) {
  rep (i, s.size()) if (s[i].b < s[i].a) swap(s[i].a, s[i].b);
  sort(s.begin(), s.end());
  rep (i, s.size()) rep (j, i) if (iSS(s[i], s[j]) && !iLL(s[i], s[j])) {
    s[j].b = max(s[i].b, s[j].b);
    s.erase(s.begin() + i--);
    break;
  }
  return s;
}

// テァツキツ堙・ツ按?」ツつ「テ」ツδャテ」ツδウテ」ツつクテ」ツδ。テ」ツδウテ」ツδ?テゥツ堋」テ」ツ?ョテァツつケテ」ツ?クテ」ツ?ョティツセツコテ」ツ?ョテ」ツ?ソテ」ツつ津ヲツ個?」ツ?、
vector<vector<int> > sArr(vector<L> s, vector<P> &vp) {
  s = merge(s);
  rep (i, s.size()) {
    vp.push_back(s[i].a);
    vp.push_back(s[i].b);
  }
  rep (i, s.size()) rep (j, i) if (iSS(s[i], s[j])) vp.push_back(pLL(s[i], s[j]));
  sort(vp.begin(), vp.end());
  vp.erase(unique(vp.begin(), vp.end(), near), vp.end());
  vector<vector<int> > g(vp.size());
  rep (i, s.size()) {
    vector<pair<D, int> > v;
    rep (j, vp.size()) if (ccw(s[i].a, s[i].b, vp[j]) == ON) {
      v.push_back(make_pair(norm(vp[j] - s[i].a), j));
    }
    sort(v.begin(), v.end());
    rep (j, v.size() - 1) {
      g[v[j + 1].second].push_back(v[j].second);
      g[v[j].second].push_back(v[j + 1].second);
    }
  }
  return g;
}

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    Pol p(n), q(m);
    rep (i, n) cin >> p[i].X >> p[i].Y;
    rep (i, m) cin >> q[i].X >> q[i].Y;
    P c;
    cin >> c.X >> c.Y;
    D res = 2 * PI;
      rep (i, n) {
	if (near(c, p[i])) continue;
	C a = (C){c, abs(c - p[i])};
	rep (j, m) {
	  L s = (L){q[j], at(q, j + 1)};
	  if (!iCL(a, s)) continue;
	  pair<P, P> pp = pCL(a, s);
	  if (ccw(s.a, s.b, pp.first) == ON) {
	    res = min(res, arg(c, pp.first, p[i]));
	  }
	  if (ccw(s.a, s.b, pp.second) == ON) {
	    res = min(res, arg(c, pp.second, p[i]));
	  }
	}
      }
      swap(n, m);
      swap(p, q);
      rep (i, n) {
	if (near(c, p[i])) continue;
	C a = (C){c, abs(c - p[i])};
	rep (j, m) {
	  L s = (L){q[j], at(q, j + 1)};
	  if (!iCL(a, s)) continue;
	  pair<P, P> pp = pCL(a, s);
	  if (ccw(s.a, s.b, pp.first) == ON) {
	    res = min(res, arg(c, p[i], pp.first));
	  }
	  if (ccw(s.a, s.b, pp.second) == ON) {
	    res = min(res, arg(c, p[i], pp.second));
	  }
	}
      }
    printf("%.12Lf\n", res * 180 / PI);
  }
  return 0;
}

Measured memory_bytes: 1292