Problem: 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

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define dbg2(x,y) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<endl
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double EPS = 1e-8, INF = 1e12, PI = acos(-1.0);
typedef complex<long double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
inline long double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline long double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;
 
inline 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(norm(b) + EPS < norm(c)) return -2;	   // a--b--c on line
	return 0;
}
inline G isCL(const P &c, long double r, const P &p1, const P &p2){
	long double x = dot(p1 - c, p2 - p1);
	long double y = norm(p2 - p1);
	long double d = x * x - y * (norm(p1 - c) - r * r);
	if(d < -EPS) return G(0);
	if(d < 0) d = 0;
	P q1 = p1 - (p2 - p1) * (x / y);
	P q2 = (p2 - p1) * (sqrt(d) / y);
	G res; res.pb(q1 - q2); res.pb(q1 + q2);
	return res;
}
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };
int contains(const G& g, const P& p) {
  bool in = false;
  for (int i = 0; i < g.size(); ++i) {
	P a = curr(g,i) - p, b = next(g,i) - p;
	if (imag(a) > imag(b)) swap(a, b);
	if (imag(a) < EPS && EPS < imag(b))
	  if (cross(a, b) < -EPS) in = !in;
	if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return ON;
  }
  return in ? IN : OUT;
}
#undef next
 
long double len, R;
int n;
 
inline double arg_(const P &p){
	double a = arg(conj(p));
	while(a < -EPS) a += 2 * PI;
	return a;
}
inline void rot(P &p, const P &c, double a){
	p = P(cos(a), sin(a)) * (p - c) + c;
}
 
int main(){
	while(cin >> len >> R >> n, n){
		R *= 2 * PI;
		 
		G g;
		rep(i, n){
			double x, y; cin >> x >> y;
			g.pb(P(x, y));
		}
		L bar(P(0, 0), P(0, len));
		P c(0, 0);
		 
		 
		int loop = 0;
		 
		while(R > EPS){
			//dbg2(bar[0], bar[1]);
			 
			long double r0 = abs(bar[0] - c);
			long double r1 = abs(bar[1] - c);
			 
			vector<pair<long double, P> > p0;
			vector<pair<long double, P> > p1;
			P next(c);
			long double nd = 0;
			 
			//頂点との交わり
			 
			rep(i, n){
				long double d = abs(g[i] - c);
				if(d < EPS) continue;
				if(d - EPS < r0){
					 
					long double a = arg_((g[i] - c) / (bar[0] - c));
					if(a > EPS) p0.pb(mp(a, g[i]));
					else if(ccw(c, g[i], g[(i + 1) % n]) == -1){
						R = -1; break;
					}
				}
				if(d - EPS < r1){
					 
					long double a = arg_((g[i] - c) / (bar[1] - c));
					if(a > EPS) p1.pb(mp(a, g[i]));
					else if(ccw(c, g[i], g[(i + 1) % n]) == -1){
						R = -1; break;
					}
				}
			}
			
			rep(i, n){
				const P &p = g[i];
				const P &q = g[(i + 1) % n];
				G g0 = isCL(c, r0, p, q);
				G g1 = isCL(c, r1, p, q);
				 
				if(r0 > EPS) rep(j, g0.size()){
					if(ccw(g0[j], p, q) != 2) continue;
					 
					long double a = arg_((g0[j] - c) / (bar[0] - c));
					if(a > EPS) p0.pb(mp(a, g0[j]));
					else{
						rot(g0[j], c, -.00005);
						if(contains(g, g0[j]) != IN){
							R = -1; break;
						}
					}
					 
				}
				if(r1 > EPS) rep(j, g1.size()){
					if(ccw(g1[j], p, q) != 2) continue;
					 
					long double a = arg_((g1[j] - c) / (bar[1] - c));
					if(a > EPS) p1.pb(mp(a, g1[j]));
					else{
						rot(g1[j], c, -.00005);
						if(contains(g, g1[j]) != IN){
							R = -1; break;
						}
					}
				}
			}
			if(R < EPS) break;
			if(!p0.size() && !p1.size()) break; //??????
			sort(all(p0)); sort(all(p1));
			 
			p0.insert(p0.end(), all(p1));
			sort(all(p0));
			 
			rep(i, p0.size()) if(abs(p0[i].first - p0[0].first) < EPS){
				long double d = abs(p0[i].second - c);
				if(d > nd + EPS){
					nd = d;
					next = p0[i].second;
				}
			}
			 
			long double ang = min(p0[0].first, R);
			R -= ang;
			rot(bar[0], c, -ang);
			rot(bar[1], c, -ang);
			c = next;
		}
		printf("%.9f %.9f\n", (double)bar[0].real(), (double)bar[0].imag());
	}
	 
	return 0;
}