#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : VP{
    L(const P& a, const P& b){ resize(2); at(0)=a; at(1)=b; }
    L(){ resize(2); }
};
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X != b.X) ? a.X<b.X : a.Y<b.Y;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1;
    if(cross(b,c) <-EPS) return -1;
    if(dot(b,c) < EPS) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

P projection(const L& l, const P& p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}

VP crosspointLC(const L &l, const C &c){
	VP ret;
	P mid = projection(l, c.p);
	double dlp = distanceLP(l, c.p);
	if(EQ(dlp, c.r)){
		ret.push_back(mid);
		return ret;
	}
	if(dlp > c.r){
		return ret;
	}
	P d = sqrt(c.r*c.r -dlp*dlp)/abs(l[1]-l[0]) *(l[1]-l[0]);
	ret.push_back(mid+d);
	ret.push_back(mid-d);
	return ret;
}
VP crosspointSC(const L &s, const C &c){
	VP ret;
	VP cp = crosspointLC(s,c);
	for(int i=0; i<(int)cp.size(); i++){
		if(dot(s[1]-s[0], cp[i]-s[0]) < 0) continue;
		if(norm(s[1]-s[0]) < norm(cp[i]-s[0])) continue;
		ret.push_back(cp[i]);
	}
	return ret;
}

double getangle(const P &p, const P &a, const P &b){ //clockwise
	P proj = projection(L(p,a), b);
	int minus = (dot(a-p, b-p)>=0)? 1 :-1;
	if(ccw(p,a,b)!=1){
		return atan2(abs(b-proj), minus*abs(p-proj));
	}else{
		return 2*M_PI - atan2(abs(b-proj), minus*abs(p-proj));
	}
}

int main(){
    while(1){
    	double l,r;
    	int n;
    	cin >> l >> r >> n;
    	r = r*2*M_PI;
    	if(n==0) break;
    	
    	VP v(n);
    	vector<L> e(n);
    	for(int i=0; i<n; i++){
    		int x,y;
    		cin >> x >> y;
    		v[i] = P(x,y);
    		e[i][1] = e[(i+1)%n][0] = P(x,y);
    	}
    	
    	P lead(0, l), follow(0, 0), fulc(0, 0);
    	bool change=false;
    	double angle_e = M_PI/2;
    	while(1){
    		double lenL = abs(lead-fulc);
    		double lenF = abs(follow-fulc);
    		P cp;
    		double rad = 2*M_PI;
    		int type = -1; //0:dot, 1:line
    		bool isL;
    		double newangle_e;
    		//lead
    		for(int i=0; i<n; i++){
    			if(EQ(v[i], fulc)) continue;
    			if(abs(v[i]-fulc) < lenL +EPS){ //inside of the circle
    				double angle = getangle(fulc, lead, v[i]);
    				if(angle < EPS) continue;
    				if(angle < rad+EPS){
    					if(EQ(angle,rad) && norm(cp-fulc)>norm(v[i]-fulc)){
    						continue;
    					}
    					cp = v[i];
    					type = 0;
    					rad = angle;
    					isL = true;
    				}
    			}
    		}
    		for(int i=0; i<n; i++){
    			VP c = crosspointSC(e[i], C(fulc, lenL));
    			for(int j=0; j<(int)c.size(); j++){
    				double angle = getangle(fulc, lead, c[j]);
    				if(angle<EPS) continue;
    				if(angle < rad+EPS){
    					if(EQ(angle,rad) && norm(cp-fulc)>norm(c[j]-fulc)){
    						continue;
    					}
    					cp = c[j];
    					type = 1;
    					rad = angle;
    					isL = true;
    					newangle_e = acos( fabs(dot(fulc-cp, e[i][0]-cp)) /
    						(abs(fulc-cp)*abs(e[i][0]-cp)));
    				}
    			}
    		}
    		//follow
    		for(int i=0; i<n; i++){
    			if(lenF == 0) break;
    			if(EQ(v[i], fulc)) continue;
    			if(abs(v[i]-fulc) < lenF +EPS){
    				double angle = getangle(fulc, follow, v[i]);
    				if(angle < EPS) continue;
    				if(angle < rad+EPS){
    					cp = v[i];
    					type = 0;
    					rad = angle;
    					isL = false;
    				}
    			}
    		}
    		for(int i=0; i<n; i++){
    			if(lenF == 0) break;
    			VP c = crosspointSC(e[i], C(fulc, lenF));
    			for(int j=0; j<(int)c.size(); j++){
    				double angle = getangle(fulc, follow, c[j]);
    				if(angle < EPS) continue;
    				if(angle < rad+EPS){
    					cp = c[j];
    					type = 1;
    					rad = angle;
    					isL = false;
    				}
    			}
    		}
    		
    		if(r < rad){
    			rad = r;
    			isL = false;
    			type = 0;
    		}
    		P rot(cos(rad), -sin(rad));
    		lead = fulc + (lead-fulc)*rot;
    		follow = fulc + (follow-fulc)*rot;
    		r -= rad;
    		//cerr << lead << " " << follow << " " << fulc << " " << type << endl;
    		if(type==0){
    			fulc = cp;
    		}else{
    			fulc = lead;
    			lead = follow;
    			follow = fulc;
    			change = !change;
    		}
    		if(!isL) break;
    		if(angle_e + rad < M_PI/2) break;
    		if(type==1){
    			angle_e = newangle_e;
    		}else{
    			angle_e = 2*M_PI;
    		}
    	}
    	
    	cout << fixed;
    	cout << setprecision(5);
    	if(change){
    		cout << lead.X << " " << lead.Y << endl;
    	}else{
    		cout << follow.X << " " << follow.Y << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 3704