Let's think about a bar rotating clockwise as if it were a twirling baton moving on a planar surface surrounded by a polygonal wall (see Figure 1).

<image>


Figure 1. A bar rotating in a polygon

Initially, an end of the bar (called "end A") is at (0,0), and the other end (called "end B") is at (0,L) where L is the length of the bar. Initially, the bar is touching the wall only at the end A.

The bar turns fixing a touching point as the center. The center changes as a new point touches the wall.

Your task is to calculate the coordinates of the end A when the bar has fully turned by the given count R.

<image>


Figure 2. Examples of turning bars

In Figure 2, some examples are shown. In cases (D) and (E), the bar is stuck prematurely (cannot rotate clockwise anymore with any point touching the wall as the center) before R rotations. In such cases, you should answer the coordinates of the end A in that (stuck) position.

You can assume the following:

> When the bar's length L changes by ε (|ε| < 0.00001), the final (x,y) coordinates will not change more than 0.0005.

Input

The input consists of multiple datasets. The number of datasets is no more than 100. The end of the input is represented by "0 0 0".

The format of each dataset is as follows:


L R N
X1 Y1
X2 Y2
...
XN YN


L is the length of the bar. The bar rotates 2π× R radians (if it is not stuck prematurely). N is the number of vertices which make the polygon.

The vertices of the polygon are arranged in a counter-clockwise order. You may assume that the polygon is simple, that is, its border never crosses or touches itself.

N, Xi and Yi are integer numbers; R and L are decimal fractions. Ranges of those values are as follows:


1.0 ≤ L ≤ 500.0,
1.0 ≤ R ≤ 10.0,
3 ≤ N ≤ 100,
-1000 ≤ Xi ≤ 1000,
-1000 ≤ Yi ≤ 1000,



X1 ≤ -1,  Y1 = 0,
X2 ≥ 1,  Y2 = 0.


Output

For each dataset, print one line containing x- and y-coordinates of the final position of the end A, separated by a space. The value may contain an error less than or equal to 0.001. You may print any number of digits after the decimal point.

Sample Input


4.0 2.0 8
-1 0
5 0
5 -2
7 -2
7 0
18 0
18 6
-1 6
4.0 2.0 4
-1 0
10 0
10 12
-1 12
4.0 1.0 7
-1 0
2 0
-1 -3
-1 -8
6 -8
6 6
-1 6
4.0 2.0 6
-1 0
10 0
10 3
7 3
7 5
-1 5
5.0 2.0 6
-1 0
2 0
2 -4
6 -4
6 6
-1 6
6.0 1.0 8
-1 0
8 0
7 2
9 2
8 4
11 4
11 12
-1 12
0 0 0


Output for the Sample Input


16.0 0.0
9.999999999999998 7.4641016151377535
0.585786437626906 -5.414213562373095
8.0 0.0
6.0 0.0
9.52786404500042 4.0


Note that the above sample input corresponds to the cases in Figure 2. For convenience, in Figure 3, we will show an animation and corresponding photographic playback for the case (C).

<image>
<image> | <image> | <image> | <image> | <image> | <image> | <image> | <image> | <image>
---|---|---|---|---|---|---|---|---

Figure 3. Animation and photographic playback for case (C)





Example

Input

4.0 2.0 8
-1 0
5 0
5 -2
7 -2
7 0
18 0
18 6
-1 6
4.0 2.0 4
-1 0
10 0
10 12
-1 12
4.0 1.0 7
-1 0
2 0
-1 -3
-1 -8
6 -8
6 6
-1 6
4.0 2.0 6
-1 0
10 0
10 3
7 3
7 5
-1 5
5.0 2.0 6
-1 0
2 0
2 -4
6 -4
6 6
-1 6
6.0 1.0 8
-1 0
8 0
7 2
9 2
8 4
11 4
11 12
-1 12
0 0 0


Output

16.0 0.0
9.999999999999998 7.4641016151377535
0.585786437626906 -5.414213562373095
8.0 0.0
6.0 0.0
9.52786404500042 4.0
#include<bits/stdc++.h>

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef long double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
typedef pair<P,D> C;

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

namespace std{
  bool operator<(const P &a,const P &b){
    return EQ(real(a),real(b))?imag(a)<imag(b):real(a)<real(b);
  }
  bool operator==(const P &a, const P &b){return EQ(a,b);}
}

//for vector
inline P unit(P p){return p/abs(p);}
inline pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

//return seta A
inline D arg(P a,P b,P c){
  D val = dot(b-a,c-a)/(abs(b-a)*abs(c-a));
  if(EQ(val,1))return 0;
  if(EQ(val,-1))return PI;
  D res =  acos(val);
  return cross(b-a,c-a)<-EPS?2*PI-res:res;
}

//for line(segment)
int ccw(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)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

//for circle
inline bool in_cir(C c,P x){return (abs(x-c.fs) +EPS < c.sc);}
inline bool on_cir(C c,P x){return EQ(abs(x-c.fs),c.sc);}

inline vector<P> cp_cir_to_line(C a, L l){
  vector<P> v;
  P n = norm(l.fs-l.sc).fs;
  P p = line_cp(l,L(a.fs,a.fs+n));

  if(on_cir(a,p))v.pb(p);
  else if(in_cir(a,p)){
    D d = abs(a.fs-p);
    D len = sqrt(a.sc*a.sc - d*d);
    P cp_vec = len * unit(l.fs-l.sc);
    v.pb(p + cp_vec);
    v.pb(p - cp_vec);
  }
  return v;
}

inline bool is_cp_cir_seg(C c, L s){
  D dis = seg_p_dis(s, c.fs);
  return (dis+EPS<c.sc);
}

struct kururin{
  P A,B,S;
  D rem_seta;
  kururin(P a=P(0,0), P b=P(0,0), P c=P(0,0), D r=0)
    :A(a),B(b),S(c),rem_seta(r){}
  void rot(D seta, P support){
    if(rem_seta < seta+EPS)seta = rem_seta;
    
    if(!EQ(A,S))A = S + rotate(A-S,2*PI-seta);
    if(!EQ(B,S))B = S + rotate(B-S,2*PI-seta);
    S = support;
    rem_seta -= seta;
  }
};

struct sup{
  D angle;
  P point;
  sup(D a=0,P p=P(0,0)):angle(a),point(p){}
  bool cmp(const sup &s,const P &c){
    if(!EQ(angle,s.angle))return angle<s.angle;
    return abs(point-c)>abs(s.point-c);
  }
};

int main(){
  D l,r,x,y;
  int n;

  while(cin >> l >> r >> n, n){
    kururin kuru(P(0,0),P(0,l),P(0,0),2*PI*r);

    Poly walls;
    rep(i,n){
      cin >> x >> y;
      walls.pb(P(x,y));
    }
    vector<L> vl;
    rep(i,n)vl.pb(L(walls[i],walls[(i+1)%n]));

    while(!EQ(kuru.rem_seta,0)){
      sup min_sup = sup(2*PI,kuru.S);

      if(!EQ(kuru.A,kuru.S)){
	C c = C(kuru.S,abs(kuru.A-kuru.S));
	rep(i,n){
	  if(is_cp_cir_seg(c,vl[i])){
	    vector<sup> angles;

	    vector<P> cp = cp_cir_to_line(c,vl[i]);
	    cp.pb(vl[i].fs); cp.pb(vl[i].sc);
	    sort(all(cp));
	    cp.erase(unique(all(cp)),cp.end());

	    rep(j,cp.sz){
	      if(ccw(vl[i].fs,vl[i].sc,cp[j])==0
		 && (in_cir(c,cp[j]) || on_cir(c,cp[j])) ){
		if(EQ(kuru.S,cp[j]))angles.pb(sup(2*PI, cp[j]));
		else{
		  angles.pb(sup(2*PI-arg(kuru.S,kuru.A,cp[j]),cp[j]));
		  if(EQ(angles.back().angle,2*PI))angles.back().angle = 0;
		}
	      }
	    }
	    
	    if(angles[1].cmp(angles[0],kuru.S))swap(angles[0],angles[1]);

	    if(EQ(angles[0].angle,0)){
	      if(para(vl[i], L(kuru.A,kuru.S))){
		if(dot(vl[i].sc-vl[i].fs, kuru.A-kuru.S) > EPS)min_sup = sup(0,kuru.S);
		else if(EQ(angles[1].angle,PI) && angles[1].cmp(min_sup,kuru.S)){
		  min_sup = angles[1];
		}
	      }else if(angles[1].angle>PI+EPS){
		if(angles[1].cmp(min_sup,kuru.S))min_sup = angles[1];
	      }else min_sup = angles[0];
	    }else if(angles[0].cmp(min_sup,kuru.S))min_sup = angles[0];
	  }
	}
      }

      if(!EQ(kuru.B,kuru.S)){
	C c = C(kuru.S,abs(kuru.B-kuru.S));
	rep(i,n){
	  if(is_cp_cir_seg(c,vl[i])){
	    vector<sup> angles;

	    vector<P> cp = cp_cir_to_line(c,vl[i]);
	    cp.pb(vl[i].fs); cp.pb(vl[i].sc);
	    sort(all(cp));
	    cp.erase(unique(all(cp)),cp.end());
	      
	    rep(j,cp.sz){
	      if(ccw(vl[i].fs,vl[i].sc,cp[j])==0
		 && (in_cir(c,cp[j]) || on_cir(c,cp[j])) ){
		if(EQ(kuru.S,cp[j]))angles.pb(sup(2*PI, cp[j]));
		else{
		  angles.pb(sup(2*PI-arg(kuru.S,kuru.B,cp[j]),cp[j]));
		  if(EQ(angles.back().angle,2*PI))angles.back().angle = 0;
		}
	      }
	    }
	  
	    if(angles[1].cmp(angles[0],kuru.S))swap(angles[0],angles[1]);

	    if(EQ(angles[0].angle,0)){
	      if(para(vl[i], L(kuru.B,kuru.S))){
		if(dot(vl[i].sc-vl[i].fs, kuru.B-kuru.S) > EPS)min_sup = sup(0,kuru.S);
		else if(EQ(angles[1].angle,PI) && angles[1].cmp(min_sup,kuru.S)){
		  min_sup = angles[1];
		}
	      }else if(angles[1].angle>PI+EPS){
		if(angles[1].cmp(min_sup,kuru.S))min_sup = angles[1];
	      }else min_sup = angles[0];
	    }else if(angles[0].cmp(min_sup,kuru.S))min_sup = angles[0];
	  }
	}

      }

      if(EQ(min_sup.angle,0))break;
      kuru.rot(min_sup.angle,min_sup.point);
    }
    cout << fixed << setprecision(8)
	 << kuru.A.real() << " " << kuru.A.imag() << endl;
  }
}