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 <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(b > a) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(b < a) a = b; }

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)

constexpr double EPS = 1e-7;

struct point {
	double x, y;
	point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
	point(const point &p):x(p.x), y(p.y) {}

	point operator+ (const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point &p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point &p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point &p) const {
		return x + EPS < p.x || (abs(x - p.x) < EPS && y + EPS < p.y);
	}

	bool operator== (const point &p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

point rotate90(const point &p) {
	return point(-p.y, p.x);
}

point rotate(const point &p, double theta) {
	const double s = sin(theta), c = cos(theta);
	return point(c * p.x - s * p.y, s * p.x + c * p.y);
}

double angle(const point &p) {
	return atan2(p.y, p.x);
}

double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

double abs(const point &p) {
	return sqrt(norm(p));
}

double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

struct line {
	point a, b;
	line(const point &a_, const point &b_):a(a_), b(b_){}
};

struct segment {
	point a, b;
	segment(const point &a_, const point &b_):a(a_), b(b_){}
};

struct circle {
	point c;
	double r;
	circle(const point &c_, const double &r_):c(c_), r(r_){}
};

typedef vector<point> polygon;

int ccw(const point &a, point b, point c) {
	b = b - a;
	c = c - a;
	const double tmp = cross(b, c);
	if(tmp > EPS) return 1; // ccw
	if(tmp < -EPS) return -1; // cw
	if(dot(b, c) < -EPS) return 2; // c, a, b 順に一直線上
	if(norm(b) + EPS < norm(c)) return -2; // a, b, c 順に一直線上
	return 0; //a, c, b 順で一直線上
}

point project(const line &l, const point &p) {
	const point dif = l.b - l.a;
	const double tmp = dot(p - l.a, dif) / norm(dif);
	return l.a + dif * tmp;
}

bool intersect(const segment &s, const segment &t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0
		&& ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool intersect(const segment &s, const point &p) {
	return ccw(s.a, s.b, p) == 0;
}

double dist(const line &l, const point &p) {
	return abs(cross(l.b - l.a, p - l.a)) / abs(l.b - l.a);
}

double dist(const segment &s, const point &p) {
	if(dot((s.b - s.a), (p - s.a)) < 0) return abs(p - s.a);
	if(dot((s.a - s.b), (p - s.b)) < 0) return abs(p - s.b);
	return dist(line(s.a, s.b), p);
}

double dist(const point &a, const point &b) {
	return abs(a - b);
}

bool intersect(const circle &c, const segment &s) {
	return dist(s, c.c) < c.r + EPS;
}

point crosspoint(const segment &s, const segment &t) {
	if(!intersect(s, t)) return point(INT_MAX, INT_MAX);

	const double tmp = cross(s.b - s.a, t.b - t.a);
	if(abs(tmp) < EPS) return point(INT_MAX, INT_MAX);
	return t.a + (t.b - t.a) * cross(s.b - s.a, s.b - t.a) * (1.0 / tmp);
}

vector<point> crosspoint(const circle &c, const line &l) {
	vector<point> res;
	const point h = project(l, c.c);
	const double d = abs(h - c.c);
	if(d > c.r - EPS) {
		res.emplace_back(h);
	}
	else if(d <= c.r - EPS) {
		point v = l.b - l.a;
		v = v * sqrt(c.r * c.r - d * d) / abs(v);
		res.emplace_back(h + v);
		res.emplace_back(h - v);
	}

	return res;
}

vector<point> crosspoint(const circle &c, const segment &s) {
	vector<point> res;
	vector<point> tmp = crosspoint(c, line(s.a, s.b));
	for(const auto &p : tmp) {
		if(intersect(s, p)) res.emplace_back(p);
	}
	return res;
}

bool touch(const point &p, const vector<segment> &walls) {
	for(const auto &s : walls) {
		if(intersect(s, p)) return true;
	}
	return false;
}

point calculate_center(const point &A, const point &B, const polygon &P) {
	const segment bar(A, B);
	double max_dist = -1.0;
	point res;

	for(const auto &p : P) {
		if(intersect(bar, p)) {
			const double d = norm(p - A);
			if(max_dist + EPS < d) {
				max_dist = d;
				res = p;
			}
		}
	}

	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(6);

	const double PI = acos(-1L);

	double L, R;
	int n;

	while(cin >> L >> R >> n && n) {
		R = R * (2 * PI);

		polygon P;
		P.reserve(n);

		rep(i, n) {
			int x, y;
			cin >> x >> y;
			P.emplace_back(-x, y);
		}

		vector<segment> walls;
		walls.reserve(n);

		rep(i, n) {
			walls.emplace_back(P[i], P[(i + 1) % n]);
		}

		point A(0, 0), B(0, L);
		bool A_is_center = true;

		while(R > EPS) { // くるくる
			point center = (A_is_center ? A : B);

			if(touch(center, walls)) {
				A_is_center = !A_is_center;
			}
			else {
				if(A_is_center) {
					center = calculate_center(B, A, P);
				}
				else {
					center = calculate_center(A, B, P);
				}
			}

			const point base_point = (A_is_center ? A : B);
			const double base_angle = angle(base_point - center);

			double min_angle = PI;

			for(const auto &p : P) {
				if(p == center) continue;
				if(norm(p - center) + EPS < L * L) {
					double theta = angle(p - center) - base_angle;
					if(theta < EPS) theta += 2 * PI;
					chmin(min_angle, theta);
				}
			}

			const circle C(center, dist(base_point, center));
			for(const auto &s : walls) {
				if(intersect(C, s)) {
					const auto cp = crosspoint(C, s);
					for(const auto &p : cp) {
						if(p == center) continue;
						double theta = angle(p - center) - base_angle;
						if(theta < EPS) theta += 2 * PI;
						chmin(min_angle, theta);
					}
				}
			}

			if(min_angle < PI) {
				const segment bar(A, B);
				for(const auto &s : walls) {
					if(!intersect(bar, s)) continue;

					const point p = project(line(s.a, s.b), center);
					const point q = crosspoint(s, bar);

					if(q.x >= INT_MAX) continue;
					if(q == s.a || q == s.b) {
						if(!(q == A || q == B)) {
							const point t = (q == s.a ? s.b : s.a);
							if(ccw(center, q, t) == 1) goto stop;
						}
						continue;
					}

					if(ccw(center, q, p) == 1) goto stop;
				}
			}

			chmin(min_angle, R);
			if(!(A == center)) A = rotate(A - center, min_angle) + center;
			if(!(B == center)) B = rotate(B - center, min_angle) + center;
			R -= min_angle;
		}
	stop:;

		cout << -A.x << " " << A.y << endl;
	}

	return EXIT_SUCCESS;
}