#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-6)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}
double arg(Vector p){ return atan2(p.y,p.x);}
Vector polar(double a,double r){ return Point(cos(r)*a,sin(r)*a);}

bool in(Circle c,Point p){
  if(abs(c.c-p)-c.r<eps)return true;
  return false;
}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

bool intersect(Circle c,Line L){
  if(getDistanceLP(L,c.c)-c.r<eps)return true;
  return false;
}

pair<Point,Point> getCrossPoints(Circle c,Line l){
  Vector pr=project(l,c.c);
  Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
  double base=sqrt(c.r*c.r-norm(pr-c.c));
  return mp(pr+e*base,pr-e*base);
}

vector<Point> getCrossPoint(Circle c,Line l){
  vector<Point> res;
  pair<Point,Point> pp=getCrossPoints(c,l);
  if(in(c,l.p1))res.pb(l.p1);
  if(in(c,l.p2))res.pb(l.p2);
  if(ccw(l.p1,l.p2,pp.f)==0)res.pb(pp.f);
  if(ccw(l.p1,l.p2,pp.s)==0)res.pb(pp.s);
  return res;
}

Point rotate(Point base,Point a,double r){
  Point b=a-base;
  a.x=b.x*cos((r/180.0)*pi)-b.y*sin((r/180.0)*pi);
  a.y=b.x*sin((r/180.0)*pi)+b.y*cos((r/180.0)*pi);
  a=a+base;
  return a;
}

double getAngle(Vector a,Vector b){
  double tmp=dot(a,b)/(abs(a)*abs(b));
  if(tmp<-1.0)tmp=-1.0;
  if(1.0<tmp)tmp=1.0;
  double r=acos(tmp)*180.0/pi;
  if(cross(a,b)<-eps)r=360.0-r;
  return r;
}

int n;
double l,r;
Polygon p;

pair<double,Point> find(Point M,Vector v){
  Circle c(M,abs(v));
  pair<double,Point> ev(inf,Point(inf,inf));
  FOR(i,0,n){
    Line L(p[i],p[(i+1)%n]);
    if(!intersect(c,L))continue;
    vector<Point> pp = getCrossPoint(c,L);
    FOR(j,0,pp.size()){
      double r1=360.0-getAngle(v,pp[j]-M);
      if(r1!=ev.f ? r1<ev.f : 
                    abs(ev.s-M)<abs(pp[j]-M))ev=mp(r1,pp[j]);
    }
  }
  return ev;
}

bool check(Point A,Point M){
  Vector v1 = M-A;
  FOR(i,0,n){
    Line L(p[i],p[(i+1)%n]);
    Vector v2 = L.p1-L.p2;
    if(!(A==p[i]) && !(M==p[i]) && 
      ccw(A,M,L.p1)==0 && ccw(A,M,L.p2)==1)return false;
    if(ccw(L.p1,L.p2,A)==0){
      double r1=getAngle(v1,v2);
      if(r1>180.0)r1=360-r1;
      if(r1-90.0<-eps)return false;
    }
  }
  return true;
}

Point solve(){
  r*=360.0;
  Point A(0,0),B(0,l),M(0,0);
  while(1){
    pair<double,Point> ev(inf,Point(inf,inf));
    if(!(A==M)){
      if(!check(A,M))break;
      pair<double,Point> res=find(M,A-M);
      if(res.f!=ev.f ? res.f<ev.f : 
                    abs(ev.s-M)<abs(res.s-M))ev=res;
    }
    if(!(B==M)){
      if(!check(B,M))break;
      pair<double,Point> res=find(M,B-M);  
      if(res.f!=ev.f ? res.f<ev.f : 
                    abs(ev.s-M)<abs(res.s-M))ev=res;
    }
    if(r-ev.f<-eps)ev.f=r;
    Point nA=rotate(M,A,360.0-ev.f);
    Point nB=rotate(M,B,360.0-ev.f);
    A=nA;
    B=nB;
    M=ev.s;
    r-=ev.f;
    if(r<eps)break;
  }
  return A;
}

int main()
{
  while(1){
    cin>>l>>r>>n;
    if(n==0)break;
    p.clear();
    FOR(i,0,n){
      int x,y;
      cin>>x>>y;
      p.pb(Point(x,y));
    }
    Point ans = solve();
    printf("%.10f %.10f\n",ans.x,ans.y);
  }
  return 0;
}

Measured memory_bytes: 3468