#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define EPS (1e-9)
#define eq(a, b) (fabs(a)-fabs(b) < EPS)
#define lt(a, b) ((a)-(b) < -EPS)
#define le(a, b) (eq(a, b) || lt(a, b))
#define PI acos(-1)

struct Point {
  double x, y;
  Point(double x=0, double y=0):x(x), y(y){}
  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(x*a, y*a); }
  Point operator / (double a) { return Point(x/a, y/a); }
  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }
  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return eq(x, p.x) && eq(y, p.y);
  }
};
typedef Point Vector;

double norm(Vector v) { return v.x*v.x+v.y*v.y; }
double abs(Vector v) { return sqrt(norm(v)); }
double dot(Vector a, Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a, Vector b) { return a.x*b.y-a.y*b.x; }

#define CCW 1
#define CW -1
#define BACK 2
#define FRONT -2
#define ON 0
int ccw(Point p, Point q, Point r) {
  Vector a = q - p, b = r - p;
  if(cross(a, b) > EPS) return CCW;
  if(cross(a, b) < -EPS) return CW;
  if(dot(a, b) < -EPS) return BACK;
  if(norm(a) < norm(b)) return FRONT;
  return ON;
}

bool intersect(Point p, Point q, Point r, Point s) {
  return (ccw(p,q,r)*ccw(p,q,s)<=0&&ccw(r,s,p)*ccw(r,s,q)<=0);
}

double distance(Point a, Point b) { return abs(a-b); }

double rad2deg(double x) { return x*180 / PI; }
double deg2rad(double x) { return x*PI / 180; }
double angle(Point a, Point b, Point c) {
  Vector v = a - b, w = c - b;
  double alpha = atan2(v.y, v.x), beta = atan2(w.y, w.x);
  if(alpha > beta) swap(alpha, beta);
  double theta = rad2deg(beta - alpha);
  return min(theta, 360-theta);
}

struct Segment {
  Point s, t;
  Segment(Point s, Point t):s(s), t(t){}
};
typedef Segment Line;

Point project(Segment s, Point p) {
  Vector base = s.t - s.s;
  double r = dot(p-s.s, base)/norm(base);
  return s.s + base*r;
}
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p)*2;
}

bool intersect(Segment s, Segment t) {
  return intersect(s.s, s.t, t.s, t.t);
}

double distanceLP(Line l, Point p) {
  return abs(cross(l.t-l.s, p-l.s)/abs(l.t-l.s));
}
double distanceSP(Segment s, Point p) {
  if(dot(s.t-s.s, p-s.s) < 0.0) return abs(p-s.s);
  if(dot(s.s-s.t, p-s.t) < 0.0) return abs(p-s.t);
  return distanceLP(s, p);
}
double distance(Segment s, Segment t) {
  if(intersect(s, t)) return 0;
  return min(min(distanceSP(s, t.s), distanceSP(s, t.t)),
	     min(distanceSP(t, s.s), distanceSP(t, s.t)));
}
Point crossPoint(Segment s, Segment t) {
  Vector base = t.t - t.s;
  double d1 = abs(cross(base, s.s-t.s));
  double d2 = abs(cross(base, s.t-t.s));
  double k = d1 / (d1 + d2);
  return s.s + (s.t-s.s)*k;
}
Point crossPointLL(Line l, Line m) {
  Vector v = l.t-l.s, w = m.t-m.s;
  double d = cross(v, w);
  if(abs(d) < EPS) return m.s;
  return l.s + v*cross(w, m.t-m.s)*(1/d);
}

struct Circle {
  Point c;
  double r;
  Circle(Point c, double r=0):c(c), r(r){}
};

typedef vector<Point> Pointlist;
Pointlist crossPoints(Circle c, Line l) {
  Pointlist res;
  Vector pr = project(l, c.c);
  if(lt(c.r, abs(c.c-pr))) return res;
  Vector e = (l.t-l.s)/abs(l.t-l.s);
  double base = sqrt(c.r*c.r-norm(pr-c.c));
  res.push_back(pr+e*base);
  if(!eq(base, 0)) res.push_back(pr-e*base);
  return res;
}

Pointlist crossPointsCS(Circle c, Segment s) {
  Pointlist res;
  Pointlist pl = crossPoints(c, s);
  for(Point p : pl) {
    if(ccw(s.s, s.t, p) == ON) res.push_back(p);
  }
  return res;
}

int M, N;
Point P[11], Q[11], C;

double solve(Point p, Segment s, bool flag) {
  double res = 360;
  double r = distance(C, p);
  Circle c(C, r);
  Pointlist pl = crossPointsCS(c, s);
  for(Point q : pl) {
    //cout<<p.x<<" "<<p.y<<" "<<C.x<<" "<<C.y<<" "<<q.x<<" "<<q.y<<endl;
    double tmp = angle(p, C, q);
    //cout<<tmp<<" "<<ccw(C,p,q)<<endl;
    if(flag) {
      if(ccw(C, p, q) == CCW) tmp = 360-tmp;
    } else {
      if(ccw(C, p, q) == CW) tmp = 360-tmp;
    }
    chmin(res, tmp);
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> M >> N, M || N) {
    rep(i, M) cin >> P[i].x >> P[i].y;
    rep(i, N) cin >> Q[i].x >> Q[i].y;
    cin >> C.x >> C.y;
    double ans = 360;
    rep(i, M) rep(j, N) {
      //cout<<i<<" "<<j<<endl;
      chmin(ans, solve(P[i], Segment(Q[j], Q[(j+1)%N]), true));
    }
    rep(i, N) rep(j, M) {
      //cout<<i<<" "<<j<<endl;
      chmin(ans, solve(Q[i], Segment(P[j], P[(j+1)%M]), false));
    }
    cout << ans << endl;
  }

  return 0;
}