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 <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;

struct C{
  P c;
  double r;
  C(P c=P(0,0), double r=0.0):c(c),r(r){}
};

double dot(P a, P b){return real(conj(a)*b);}
double cross(P a, P b){return imag(conj(a)*b);}
bool equal(double a, double b){return fabs(a-b) < EPS;}

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

bool isInterSP(L s, P p){
  if(dot(s.second - s.first, p - s.first) < -EPS) return equal(0.0, abs(p-s.first));
  if(dot(s.first - s.second, p - s.second) < - EPS) return equal(0.0, abs(p-s.second));
  return equal(0.0, abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first)));
}

vector<P> getInterCS(C c, L s){
  vector<P> res;
  P h = proj(c.c, s);
  double d = abs(c.c - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isInterSP(s, h)) res.push_back(h);
  } else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isInterSP(s, h+v)) res.push_back(h+v);
    if(isInterSP(s, h-v)) res.push_back(h-v);
  }
  return res;
}

int n,m;
vector<P> v[2];
P ce;

double calc(P a, P b1, P b2){
  double res = arg(b2-a) - arg(b1-a);
  res *= 180.0 / M_PI;
  while(res < 0) res += 360.0;
  while(res > 360.0) res -= 360.0;
  return res;
}

void solve(){
  double ans = 360.0;
  for(int i=0;i<m;i++){
    C c = C(ce, abs(ce-v[1][i]));
    for(int j=0;j<n;j++){
      L l = L(v[0][j], v[0][(j+1)%n]);
      vector<P> cp = getInterCS(c, l);
      for(int k=0;k<cp.size();k++)
	ans = min(ans, calc(ce, v[1][i], cp[k]));
    }
  }

  for(int i=0;i<n;i++){
    C c = C(ce, abs(ce-v[0][i]));
    for(int j=0;j<m;j++){
      L l = L(v[1][j], v[1][(j+1)%m]);
      vector<P> cp = getInterCS(c, l);
      for(int k=0;k<cp.size();k++)
	ans = min(ans, calc(ce, cp[k], v[0][i]));
    }
  }


  printf("%.7f\n",ans);
}

int main(){
  while(cin >> n >> m && (n|m)){
    double x,y;
    for(int i=0;i<2;i++) v[i].clear();
    for(int i=0;i<n;i++){
      cin >> x >> y;
      v[0].push_back(P(x,y));
    }
    for(int i=0;i<m;i++){
      cin >> x >> y;
      v[1].push_back(P(x,y));
    }
    cin >> x >> y;
    ce = P(x,y);
    solve();
  }
}