#include<iostream>
#include<complex>
#include<cmath>
#include<cassert>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair

typedef complex<double> P;
typedef pair<double,double> pdd;
typedef pair<double,P> pdp;
const double eps = 1e-6;
const double pi = acos(-1);
const pdp nocand=mp(6*pi,P(0,0));
const int N = 100;

//move A to B
double computeAngle(P a,P b){
  double tmp = arg(a/b);
  if (tmp < -eps)tmp+=(2*pi);
  return tmp;
}

double cross(P a,P b){
  return ( a.real()*b.imag() - a.imag()*b.real());
}

double myabs(P a){
  return sqrt(a.real()*a.real()+a.imag()*a.imag());
}

bool isp(P a,P b,P c){
  return myabs(a-c)+myabs(b-c) < myabs(a-b) + eps;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  //if ( isp(a1,a2,b1))return true;
  //if ( isp(a1,a2,b2))return true;
  //if ( isp(b1,b2,a1))return true;
  //if ( isp(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-eps ) && //-EPS
        ( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-eps))return true;
  else return false;
}

bool is_in(int n,const P* in,P a){
  int cnt =0;
  rep(i,n){
    P cur = in[i]-a,next=in[(i+1)%n]-a;
    if (cur.imag() > next.imag())swap(cur,next);
    if (cur.imag()<0 && 0<=next.imag() &&
	cross(next,cur)>=0)cnt++;
    if (isp(in[i],in[(i+1)%n],a))return true;
  }

  if (cnt %2 == 1)return true;
  else return false;
}

pdp getpoint(P &o,P & a,const double r,const P & b){
  if (myabs(b-o) < r+eps){
    double angle=computeAngle(a-o,b-o);
    return mp(angle,b);
  }else return nocand;
}

P getcircle_line_intersection(double rx,double ry,double dx,double dy,double t){
  return P(dx*t,dy*t);
}

pdd check(double dx,double dy,double rx,double ry,double r,bool &f){
  double a=(dx*dx+dy*dy),b=-2*rx*dx-2*ry*dy,c=rx*rx+ry*ry-r*r;
  double D=b*b-4*a*c;
  if (D < 0){
    f=false;
    return mp(-1,-1);
  }else {
    f=true;
    return mp((-b-sqrt(D))/(2*a),(-b+sqrt(D))/(2*a));
  }
}


P rotate(P o,P a,double theta){
  P ret;
  P tmp=a-o;
  double c=cos(-theta),s=sin(-theta);
  double x=tmp.real(),y=tmp.imag();
  ret.real()=x*c-y*s;
  ret.imag()=x*s+y*c;
  return o+ret;
}

/*
bool can_rotate(P &o,P & stick,double r,const P &a,const P& b){
  P tmp=rotate(o,stick,1e-10*1000);
  //printf("%.10lf %.10lf , %.10lf %.10lf %d\n",
  //tmp.real(),tmp.imag(),stick.real(),stick.imag(),
  //is_intersected_ls(o,tmp,a,b));
  return !(is_intersected_ls(o,tmp,a,b));
}
*/
/*
bool can_rotate(P &o,P &stick,double r,const P&a,const P&b){
  bool haveans=false;
  P D=b-a,R=o-a;
  D/=myabs(D);
  double dx=D.real(),dy=D.imag(),rx=R.real(),ry=R.imag();
  pdd tmp=check(dx,dy,rx,ry,r,haveans);
  if (!haveans)return true;
  P in[2]={getcircle_line_intersection(rx,ry,dx,dy,tmp.first )+a,
           getcircle_line_intersection(rx,ry,dx,dy,tmp.second)+a};
  double angle[2]={
    computeAngle(stick-o,in[0]-o),
    computeAngle(stick-o,in[1]-o)
  };
  if (angle[1] > angle[0])swap(angle[0],angle[1]);
  if (fabs(angle[0]-angle[1])<eps)return true;
  double mid = (angle[0]+angle[1])/2;
  P rot = rotate(o,stick,mid);
  double ccw[2]={
    cross(b-a,o-a),
    cross(b-a,rot-a)
  };
  if (fabs(ccw[0])<eps||fabs(ccw[1])<eps)
    return true;
  return (ccw[0]<eps&&ccw[1]<eps)||(ccw[0]>-eps&&ccw[1]>-eps);
}
*/

pdp getlines(P &o,P stick,double r,const P &a,const P &b){
  bool haveans=false;
  P D=b-a,R=o-a;
  D/=myabs(D);
  double dx=D.real(),dy=D.imag(),rx=R.real(),ry=R.imag();
  pdd tmp=check(dx,dy,rx,ry,r,haveans);
  if (!haveans)return nocand;
  pdp ret=nocand;
  P in[2]={getcircle_line_intersection(rx,ry,dx,dy,tmp.first )+a,
           getcircle_line_intersection(rx,ry,dx,dy,tmp.second)+a};
  rep(i,2){
    if (!isp(a,b,in[i]))continue;
    double tang=computeAngle(stick-o,in[i]-o);
    if (tang < eps){
      continue;
    }
    if (tang < ret.first){
      ret.first =tang;
      ret.second=in[i];
    }
  }
  return ret;
}

P solve(P *a,int n,const P *in,double all){
  P center=a[0];
  double total=0;
  while(total < all){
    double mini=4*pi;
    P next=(1e10,1e10);
    const double r[2]={myabs(center-a[0]),myabs(center-a[1])};
    bool canrotate=true;
    /*
    rep(j,2){
      if (r[j] < eps)continue;
      rep(i,n){
        if (isp(in[i],in[(i+1)%n],a[j])&&
            !can_rotate(center,a[j],r[j],in[i],in[(i+1)%n])){
	  //cout <<"cannot rotate " << endl;
          canrotate=false;
          break;
        }
      }
    }
    if (!canrotate)break;
    */

    //for all line
    rep(j,2){
      if (r[j] < eps)continue;
      rep(i,n){
        pdp tmp=getlines(center,a[j],r[j],in[i],in[(i+1)%n]);
        if (eps < tmp.first && tmp.first < mini){
          mini=tmp.first;
          next=tmp.second;
        }else if (fabs(tmp.first-mini) < eps &&
                  myabs(next-center) < myabs(tmp.second-center)){
          mini=tmp.first;
          next=tmp.second;
        }
      }
    }

    //for all point
    rep(j,2){
      if (r[j] < eps)continue;
      rep(i,n){
        pdp tmp=getpoint(center,a[j],r[j],in[i]);
        //if (eps < tmp.first && tmp.first < mini-eps){
        if (eps < tmp.first && tmp.first < mini-eps){
          mini=tmp.first;
          next=tmp.second;
        }else if (fabs(tmp.first-mini) < eps &&
                  myabs(next-center) < myabs(tmp.second-center)){
          mini=tmp.first;
          next=tmp.second;
        }
      }
    }

    if (mini > 2*pi)break;//no candidate
    if (total + mini >= all){
      mini=all-total;
    }

    //can rotate ??
    rep(j,2){
      if (r[j] < eps)continue;
      P rot=rotate(center,a[j],mini/2);
      rep(i,n){
	if (is_intersected_ls(center,rot,in[i],in[(i+1)%n])){
	  canrotate=false;
	  break;
	}
      }
      if (!is_in(n,in,a[j]))canrotate=false;
    }

    if (!canrotate)break;

    //rotate
    rep(i,2){
      if (myabs(center-a[i])<eps)continue;
      a[i]=rotate(center,a[i],mini);
    }
    
    center=next;
    total+=mini;
    //cout << mini*180/pi <<" " << next<<endl;
    //cout <<"next point " << a[0]<<" " << a[1] << endl;
    //cout <<"end condition check " << total <<" " << all << endl;
    if (mini < eps)break;
  }
  return a[0];
}

main(){
  double l,r;
  int n;
  P in[N];
  while(cin>>l>>r>>n && n){
    rep(i,n)cin>>in[i].real()>>in[i].imag();
    P a[2]={P(0,0),P(0,l)};
    r*=2*pi;
    P ans=solve(a,n,in,r);
    printf("%.10lf %.10lf\n",ans.real()+0,ans.imag()+0.0);
    //cout <<"this case is end" << endl;
  }
  return false;
}

Measured memory_bytes: 0