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<bits/stdc++.h>
using namespace std;

const double PI=acos(-1);
const double PI2=PI*2.0;
const double eps=1e-10;

typedef complex<double> P;
typedef pair<P,P> S;
typedef pair<P,double> C;
typedef vector<P> vecP;

bool eq(double a,double b){
  return -eps<a-b&&a-b<eps;
}

double Sqrt(double x){
  if(x<0)return x;
  return sqrt(x);
}

P normal( P a ){
  return a/abs(a);
}

double dot(P a,P b){
  return real( b*conj(a) );
}
double cross(P a,P b){
  return imag( b*conj(a) );
}
double getArg(P a,P b){
  return arg(b*conj(a));
}

double getTime(P a,P b){
  return ( dot(a,b) < 0 ? -1.0 : 1.0)*abs(b)/abs(a);  
}

bool onSP(S s,P p){
  P a=s.first, b=s.second;
  return eq( abs(a-b) , abs(p-a)+abs(p-b) );
}

P project(P a,P b,P c){
  b-=a;c-=a;
  return a+b*real(c/b);
}

double getDistLP(S s,P p){
  P a=s.first, b=s.second;
  return abs( cross(b-a,p-a) / abs(b-a) );
}

double getDistSP(S s,P p){
  P a=s.first, b=s.second;
  if( dot(b-a,p-a) < eps )return abs(p-a);
  if( dot(a-b,p-b) < eps )return abs(p-b);
  return getDistLP(s,p);
}

bool isCrossCS(C c,S s){
  P a=s.first, b=s.second;
  double A=abs(c.second-a);
  double B=abs(c.second-b);
  double C=getDistSP(s,c.second);
  if( A < c.second+eps  && B < c.second+eps )return false;
  if( c.second+eps < C )return false;
  return true;
}

vecP getCrossCL(C cir,S line){
  P a=line.first, b=line.second;
  double cr=cir.second;
  P cp=cir.first;
  vecP res;
  P base=b-a, target=project(a,b,cp);
  double length=abs(base), h=abs(cp-target);
  base/=length;

  if(cr+eps<h)return res;
  double w=Sqrt(cr*cr-h*h);
  double L=getTime( normal(b-a), target-a) -w , R=L+w*2.0;

  res.push_back( a+ base * L );
  if(eq(L,R))return res;
  res.push_back( a+ base * R );
  return res;
}

vecP getCrossCS(C cir,S s){
  vecP tmp=getCrossCL(cir,s);
  vecP res;
  for(int i=0;i<(int)tmp.size();i++)
    if( onSP(s,tmp[i]) )
      res.push_back( tmp[i] );

  return res;
}

double calc(P cen,S a,P b){
  if( eq(abs(cen-b),0) )return 1e10;
  
  vecP tp=getCrossCS( C(cen, abs(cen-b) ) , a );
  double res=1e10;
  
  for(int i=0;i<(int)tp.size();i++){
    P p=tp[i];
    double value=getArg(b-cen,p-cen);
    if( value < 0 )value+=PI2;
    res=min(res,value);
  }
  return res;
}

double calc2(P cen,S a,P b){
  if( eq(abs(cen-b),0) )return 1e10;
  
  vecP tp=getCrossCS( C(cen, abs(cen-b) ) , a );
  double res=1e10;
  
  for(int i=0;i<(int)tp.size();i++){
    P p=tp[i];
    double value=getArg(b-cen,p-cen);
    if( value < 0 )value+=PI2;
    res=min(res,PI2-value);
  }
  return res;
}

double calc(P cen,S a,S b){
  double res=1e10;
  res=min(res,calc(cen,a,b.first));
  res=min(res,calc(cen,a,b.second));
  res=min(res,calc2(cen,b,a.first));
  res=min(res,calc2(cen,b,a.second));
  return res;
}

P input(){
  int x,y;
  cin>>x>>y;
  return P(x,y);
}


S getS(const vecP& polygon,int index){
  int n=polygon.size();
  index%=n;
  return S(polygon[index], polygon[ (index+1) % n ]);
}

int main(){
  int M,N;
  P cen;
  while(1){
    cin>>M>>N;
    if(M==0&&N==0)break;
    vecP inpol,outpol;
    
    for(int i=0;i<M;i++){
      inpol.push_back( input() );
    }
    for(int i=0;i<N;i++){
      outpol.push_back( input() );
    }
    cen=input();

    double ans=1e10;
    for(int i=0;i<M;i++){
      for(int j=0;j<N;j++){
        ans=min(ans, calc(cen, getS(inpol,i) , getS(outpol,j) ) );
      }
    }
    printf("%.10f\n", min(360.0,ans/PI*180.0) );
  }
  return 0;
}