#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <utility>
#include <vector>
namespace lc {
static const double EPS = 1e-9;
inline double abs(double x){ return std::abs(x); }
}
namespace lc {
struct Point {
	double x;
	double y;
	explicit Point(const double &x = 0.0, const double &y = 0.0) :
		x(x), y(y)
	{ }
	Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
	Point &operator+=(const Point &p){ return *this = *this + p; }
	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); }
	double abs() const { return sqrt(x * x + y * y); }
	double norm() const { return x * x + y * y; }
	Point unit() const { return *this / abs(); }
	Point ortho() const { return Point(-y, x); }
	double arg() const { return atan2(y, x); }
};
inline Point operator*(double s, const Point &p){ return p * s; }
inline double cross(const Point &a, const Point &b){
	return a.x * b.y - a.y * b.x;
}
inline double dot(const Point &a, const Point &b){
	return a.x * b.x + a.y * b.y;
}
inline int ccw(const Point &a, const Point &b, const Point &c){
	Point d = b - a, e = c - a;
	if(cross(d, e) > 0.0){ return 1; }
	if(cross(d, e) < 0.0){ return -1; }
	if(dot(d, e) < 0.0){ return 2; }
	if(d.abs() < e.abs()){ return -2; }
	return 0;
}
}
namespace lc {
struct Line {
	Point a;
	Point b;
	explicit Line(const Point &a = Point(), const Point &b = Point()) :
		a(a), b(b)
	{ }
	Point projection(const Point &p) const {
		double t = dot(p - a, b - a) / (b - a).norm();
		return a + t * (b - a);
	}
	Point direction() const {
		return (b - a).unit();
	}
};
inline bool tolerant_eq(const Line &a, const Line &b){
	const double x = abs(cross(a.b - a.a, b.b - b.a));
	const double y = abs(cross(a.b - a.a, a.b - b.a));
	return x < EPS && y < EPS;
}
inline int ccw(const Line &l, const Point &p){
	return ccw(l.a, l.b, p);
}
}
namespace lc {
struct Segment {
	Point a;
	Point b;
	explicit Segment(const Point &a = Point(), const Point &b = Point()) :
		a(a), b(b)
	{ }
	Line to_line() const { return Line(a, b); }
	double length() const { return (b - a).abs(); }
	Point direction() const {
		return (b - a).unit();
	}
};
}
namespace lc {
struct Circle {
	Point c;
	double r;
	explicit Circle(const Point &c = Point(), double r = 0.0) :
		c(c), r(r)
	{ }
	int contains(const Point &p) const {
		const double d2 = (p - c).norm(), r2 = r * r;
		if(d2 > r2){ return 0; }
		if(d2 < r2){ return 1; }
		return -1;
	}
};
}
namespace lc {
inline bool intersect(const Point &a, const Line &b){
	return abs(cross(b.b - a, b.a - a)) < EPS;
}
inline bool intersect(const Line &a, const Point &b){
	return intersect(b, a);
}
inline bool intersect(const Point &a, const Segment &b){
	return (b.a - a).abs() + (b.b - a).abs() - (b.b - b.a).abs() < EPS;
}
inline bool intersect(const Segment &a, const Point &b){
	return intersect(b, a);
}
}
namespace lc {
inline std::vector<Point> crossing_points(const Line &l, const Circle &c){
	const Point &p = l.projection(c.c);
	const double t = (p - c.c).abs();
	if(t > c.r + EPS){ return std::vector<Point>(); }
	if(t > c.r - EPS){ return std::vector<Point>(1, p); }
	const Point v = l.direction();
	const double d = sqrt(c.r * c.r - t * t);
	return std::vector<Point>({ p + d * v, p - d * v });
}
inline std::vector<Point> crossing_points(const Segment &s, const Circle &c){
	const std::vector<Point> cps(crossing_points(s.to_line(), c));
	std::vector<Point> result;
	for(const auto &p : cps){
		if(intersect(s, p)){ result.push_back(p); }
	}
	return result;
}
}
using namespace std;
static const double EPS = lc::EPS;
pair<double, double> solve(
	const lc::Segment &bar, const vector<lc::Point> &poly)
{
	if(bar.length() < EPS){ return make_pair(2.0 * M_PI, 0.0); }
	const int n = poly.size();
	const lc::Circle c(bar.a, bar.length());
	const double base_arg = bar.direction().arg();
	double min_rot = 2.0 * M_PI, max_dist = 0.0;
	for(int i = 0; i < n; ++i){
		const lc::Segment edge(poly[i], poly[(i + 1) % n]);
		auto cps = crossing_points(edge, c);
		if(c.contains(edge.a)){ cps.push_back(edge.a); }
		if(c.contains(edge.b)){ cps.push_back(edge.b); }
		for(const auto &p : cps){
			if((p - bar.a).abs() < EPS){ continue; }
			double arg = base_arg - (p - bar.a).arg();
			while(arg <= -EPS){ arg += 2.0 * M_PI; }
			if(abs(arg) < EPS){
				const lc::Line ortho(
					bar.b + bar.direction().ortho(), bar.b);
				if(lc::tolerant_eq(bar.to_line(), edge.to_line())){
					arg = 2.0 * M_PI;
				}else if(
					!lc::intersect(bar.to_line(), edge.a) &&
					lc::ccw(bar.to_line(), edge.a) == -1)
				{
					if(lc::ccw(ortho, edge.a) != -1){ arg = 2.0 * M_PI; }
				}else if(
					!lc::intersect(bar.to_line(), edge.b) &&
					lc::ccw(bar.to_line(), edge.b) == -1)
				{
					if(lc::ccw(ortho, edge.b) != -1){ arg = 2.0 * M_PI; }
				}else{
					arg = 2.0 * M_PI;
				}
			}
			if(arg < min_rot){
				min_rot = arg;
				max_dist = (p - bar.a).abs();
			}else if(arg == min_rot){
				max_dist = max(max_dist, (p - bar.a).abs());
			}
		}
	}
	return make_pair(min_rot, max_dist);
}
int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	while(true){
		double l, r;
		int n;
		cin >> l >> r >> n;
		if(l == 0.0 && r == 0.0 && n == 0){ break; }
		vector<lc::Point> outline(n);
		for(int i = 0; i < n; ++i){ cin >> outline[i].x >> outline[i].y; }
		lc::Segment bar[2] = {
			lc::Segment(lc::Point(0, 0), lc::Point(0, l)),
			lc::Segment(lc::Point(0, 0), lc::Point(0, 0))
		};
		int flip = 0;
		r *= 2.0 * M_PI;
		while(r > EPS){
			const auto head_ret = solve(bar[0], outline);
			const auto tail_ret = solve(bar[1], outline);
			const double rot = min(r, min(head_ret.first, tail_ret.first));
			if(rot < EPS){ break; }
			const lc::Point trans_rot(cos(rot), -sin(rot));
			for(int i = 0; i < 2; ++i){
				if(bar[i].length() < EPS){ continue; }
				bar[i].b = bar[i].a + (bar[i].b - bar[i].a) * trans_rot;
			}
			const double shift =
				head_ret.first <= tail_ret.first ?
					head_ret.second : -tail_ret.second;
			const lc::Point trans_shift = (bar[0].b - bar[1].b).unit() * shift;
			bar[0].a += trans_shift;
			bar[1].a += trans_shift;
			if(bar[0].length() < EPS){
				swap(bar[0], bar[1]);
				flip = 1 - flip;
			}
			r -= rot;
		}
		const lc::Point answer = bar[1 - flip].b;
		cout << answer.x << " " << answer.y << endl;
	}
	return 0;
}

Measured memory_bytes: 1388