#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <utility>
#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; //counter clockwise
    if(cross(b,c) <-EPS) return -1; //clockwise
    if(dot(b,c) < EPS) return +2; //c-a-b
    if(norm(b) < norm(c)) return -2; //a-b-c
    return 0; //a-c-b
}

int lccw(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
    return 0;
}

bool intersectLL(const L& l, const L& m){
    return ( abs(cross(l[1]-l[0], m[1]-m[0])) > EPS ) ||
        ( abs(cross(l[1]-l[0], m[0]-l[0])) < EPS );
}
bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectLP(const L& l, const P& p){
    return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L& s, const L& t){
    return ( ccw(s[0],s[1],t[0]) *ccw(s[0],s[1],t[1]) <= 0 ) &&
        ( ccw(t[0],t[1],s[0]) *ccw(t[0],t[1],s[1]) <= 0 );
}
bool intersectSP(const L& s, const P& p){
    return abs(s[0]-p) +abs(s[1]-p) -abs(s[1]-s[0]) < EPS;
}

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]);
}
P reflection(const L& l, const P& p) {
  return p + 2.0*(projection(l, p) -p);
}

double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min( distanceLP(l, s[0]), distanceLP(l, s[1]) );
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0]-p), abs(s[1]-p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B /A *(m[1]-m[0]);
}

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