#include<cmath>
#include<algorithm>
#include<cassert>
////////////////////
// ??¨????????¢???
using D = double;
////////////////////
// ?????°
const D EPS = 1e-9;                // |EPS|???????????°???0??¨????????±???
enum POSITION {ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK};   // 3??????????????¢???
////////////////////
// ?§???????
struct Point {
  D x, y;
  Point(const D d = 0.0) : x(d), y(d) {}
  Point(const D x, const D y) : x(x), y(y) {}
};
struct Segment {
  Point ab, to;
  Segment(const Point& ab, const Point& to) : ab(ab), to(to) {}
  Segment(const D x1, const D y1, const D x2, const D y2) : ab(x1, y1), to(x2, y2) {}
};
struct Line {
  Point ab, to;
  Line(const Point& ab, const Point& to) : ab(ab), to(to) {}
  Line(const D x1, const D y1, const D x2, const D y2) : ab(x1, y1), to(x2, y2) {}
  Line(const Segment& s) : ab(s.ab), to(s.to) {}
};
////////////////////
// ????£?
bool relative_equal(const D d1, const D d2) {return d1 == 0 ? std::abs(d2) < EPS : std::abs((d1 - d2) / d1) < EPS;}
// ??????????????????????????????
bool operator==(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) && relative_equal(lhs.y, rhs.y);}
bool operator<(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y < rhs.y : lhs.x < rhs.x;}
bool operator>(const Point& lhs, const Point& rhs) {return relative_equal(lhs.x, rhs.x) ? lhs.y > rhs.y : lhs.x > rhs.x;}
bool operator!=(const Point& lhs, const Point& rhs) {return !(lhs == rhs);}
bool operator<=(const Point& lhs, const Point& rhs) {return !(lhs > rhs);}
bool operator>=(const Point& lhs, const Point& rhs) {return !(lhs < rhs);}
const Point operator+(const Point& lhs, const Point& rhs) {return Point(lhs.x + rhs.x, lhs.y + rhs.y);}
const Point operator-(const Point& lhs, const Point& rhs) {return Point(lhs.x - rhs.x, lhs.y - rhs.y);}
const Point operator*(const Point& lhs, const Point& rhs) {return Point(lhs.x * rhs.x, lhs.y * rhs.y);}
const Point operator/(const Point& lhs, const Point& rhs) {return Point(lhs.x / rhs.x, lhs.y / rhs.y);}
const Point operator-(const Point& p) {return Point(-p.x, -p.y);}
// ???
D abs(const Point& p) {return std::hypot(p.x, p.y);}
D norm(const Point& p) {return p.x * p.x + p.y * p.y;}
D dot(const Point& a, const Point& b) {return a.x * b.x + a.y * b.y;}
D cross(const Point& a, const Point& b) {return a.x * b.y - a.y * b.x;}
// ??´???
bool parallel(const Line& l1, const Line& l2) {return relative_equal(0.0, cross(l2.to - l2.ab, l1.to - l1.ab));}
bool orthogonal(const Line& l1, const Line& l2) {return relative_equal(0.0, dot(l2.to - l2.ab, l1.to - l1.ab));}
// 3??????????????¢???
POSITION ccw(const Point& a, const Point& b, const Point& p) {
  Point v1 = b - a;
  Point v2 = p - a;
  if(cross(v1, v2) >= EPS) return COUNTER_CLOCKWISE;
  if(cross(v1, v2) <= -EPS) return CLOCKWISE;
  if(dot(v1, v2) <= -EPS) return ONLINE_BACK;
  if(norm(v1) < norm(v2)) return ONLINE_FRONT;              // ????????????: norm(v1)<norm(v2)+EPS?????¨WrongAnswer
  return ON_SEGMENT;
}
// ????????????
bool intersect(const Point& p1, const Point& p2) {return p1 == p2;}
bool intersect(const Point& p, const Segment& s) {return abs(p - s.ab) + abs(p - s.to) - abs(s.ab - s.to) <= EPS;}
bool intersect(const Segment& s, const Point& p) {return intersect(p, s);}
bool intersect(const Point& p, const Line& l) {return !parallel(Line(p, l.ab), Line(p, l.to));}
bool intersect(const Line& l, const Point& p) {return intersect(p, l);}
bool intersect(const Segment& s1, const Segment& s2) {
  return ccw(s1.ab, s1.to, s2.ab) * ccw(s1.ab, s1.to, s2.to) <= 0
      && ccw(s2.ab, s2.to, s1.ab) * ccw(s2.ab, s2.to, s1.to) <= 0;
}
bool intersect(const Segment& s, const Line& l) {
  auto v1 = l.to - l.ab;
  auto v2 = s.ab  - l.ab;
  auto v3 = s.to - l.ab;
  return cross(v1, v2) * cross(v1, v3) <= EPS;
}
bool intersect(const Line& l, const Segment& s) {return intersect(s, l);}
bool intersect(const Line& l1, const Line& l2) {return !parallel(l1, l2) || intersect(l1.ab, l2);}
// ???????§????
Point rotate(const Point& p, const D a) {return Point(p.x * std::cos(a) - p.y * std::sin(a), p.x * std::sin(a) + p.y * std::cos(a));}
Point projection(const Point& p, const Line& l) {
  auto v = l.ab - l.to;
  return l.ab + dot(p - l.ab, v) / norm(v) * v;
}
Point projection(const Line& l, const Point& p) {return projection(p, l);}
Point reflection(const Point& p, const Line& l) {return p + 2 * (projection(p, l) - p);}
Point reflection(const Line& l, const Point& p) {return reflection(p, l);}
// ?????¢
D distance(const Point& p1, const Point& p2) {
  auto p = p1 - p2;
  return hypot(p.x, p.y);
}
D distance(const Point& p, const Segment& s) {
  auto r = projection(s, p);
  return intersect(r, s) ? distance(p, r) : std::min(distance(p, s.ab), distance(p, s.to));
}
D distance(const Segment& s, const Point& p) {return distance(p, s);}
D distance(const Point& p, const Line& l) {return distance(p, projection(p, l));}
D distance(const Line& l, const Point& p) {return distance(p, l);}
D distance(const Segment& s1, const Segment& s2) {
  return intersect(s1, s2) ? 0.0 : std::min({distance(s1, s2.ab), distance(s1, s2.to), distance(s2, s1.ab), distance(s2, s1.to)});
}
D distance(const Segment& s, const Line& l) {return intersect(s, l) ? 0.0 : std::min(distance(s.ab, l), distance(s.to, l));}
D distance(const Line& l,const Segment& s) {return distance(s, l);}
D distance(const Line& l1, const Line& l2) {return intersect(l1, l2) ? 0.0 : distance(l1.ab, l2);}
// ??????
const Point crosspoint(const Line& l1, const Line& l2) {
  assert(intersect(l1, l2));
  if(parallel(l1, l2)) return l1.ab;                   // ???????????¨???l1????§?????????????
  D A = cross(l1.to - l1.ab, l2.to - l2.ab);
  D B = cross(l1.to - l1.ab, l1.to - l2.ab);
  return l2.ab + B / A * (l2.to - l2.ab);
}
const Point crosspoint(const Segment& s, const Line& l) {
  assert(intersect(s, l));
  if(parallel(s, l)) return s.ab;
  return crosspoint(Line(s), l);
}
const Point crosspoint(const Line& l, const Segment& s) {return crosspoint(s, l);}
const Point crosspoint(const Segment& s1, const Segment& s2) {
  assert(intersect(s1, s2));
  if(parallel(s1, s2)) {                                    // ???????????¨?????????????????????????????????
    if(intersect(s1.ab,  s2)) return s1.ab;
    if(intersect(s1.to, s2)) return s1.to;
    if(intersect(s2.ab,  s1)) return s2.ab;
    if(intersect(s2.to, s1)) return s2.to;
  }
  return crosspoint(Line(s1), Line(s2));
}
// ???????????°??¨
#include<iostream>
std::ostream& operator<<(std::ostream& os, const Point& p) {os<<"point: "; os<<"("<<p.x<<","<<p.y<<")"; return os;}
std::ostream& operator<<(std::ostream& os, const Segment& s) {os<<"segment: "; os<<s.ab<<" - "<<s.to; return os;}
std::ostream& operator<<(std::ostream& os, const Line& l) {os<<"line: "; os<<l.ab<<" - "<<l.to; return os;}
////////////////////////////////////////////////////////////////////////////////
// ???
#include<vector>
const D PI = std::acos(-1);
struct Circle {
  Point center;
  D radius;
  Circle(const Point& center = 0, const D radius = 1) : center(center), radius(radius) {}
  Circle(const D x, const D y, const D radius) : center(x, y), radius(radius) {}
};
// ????????¢???
bool contain(const Circle& c, const Point& p) {
  D d = distance(c.center, p);
  if(relative_equal(c.radius, d)) return true;
  return d < c.radius;
}
bool contain(const Point& p, const Circle& c) {return contain(c, p);}
bool intersect(const Circle& c, const Segment& s) {
  D d = distance(c.center, s);
  if(relative_equal(c.radius, d)) return true;
  return d < c.radius;
}
bool intersect(const Segment& s, const Circle& c) {return intersect(s, c);}
// ??±?????\???
int tangent(const Circle& c1, const Circle& c2) {
  D d = distance(c1.center, c2.center);
  D r = c1.radius + c2.radius;
  if(relative_equal(d, r)) return 3;    // ?????\
  if(r < d) return 4;                   // ?????¢
  r = std::abs(c1.radius - c2.radius);
  if(relative_equal(d, r)) return 1;    // ?????\
  if(r < d) return 2;                   // ??????
  return 0;                             // ??????
}
// ??????
std::vector<Point> crosspoint(const Circle& c, const Line& l) {
  std::vector<Point> cp;
  Point p = projection(c.center, l);
  if(!contain(c, p)) return cp;
  Point v = p - c.center;
//   if(relative_equal(abs(v), 0)) {
  if(abs(v)<EPS) {
    Point p = l.ab - c.center;
    if(p == 0) p = l.to - c.center;
    p = (c.radius * p / abs(p));
    cp.push_back(c.center + p);
    cp.push_back(c.center - p);
    return cp;
  }
  D angle = acos(abs(v) / c.radius);
  for(D a: {angle, -angle}) cp.push_back(c.center + c.radius * (rotate(v, a) / abs(v)));
  return cp;
}
std::vector<Point> crosspoint(const Line& l, const Circle& c) {return crosspoint(c, l);}
std::vector<Point> crosspoint(const Circle& c1, const Circle& c2) {
  assert(tangent(c1, c2) != 4);
  std::vector<Point> cp;
  D angle = atan2(c2.center.y - c1.center.y, c2.center.x - c1.center.x);
  D d = distance(c1.center, c2.center);
  D add = acos((d * d + c1.radius * c1.radius - c2.radius * c2.radius) / (2.0 * d * c1.radius));
  for(D a: {angle + add, angle - add}) cp.push_back(c1.center + c1.radius * Point(std::cos(a), std::sin(a)));
  return cp;
}

#include<bits/stdc++.h>
using namespace std;

D L, R;
int N;
vector<Segment> P;

const D INF = 1e9;

bool contain(vector<Segment> P, Point p) {
  bool in = false;
  for(auto s: P) {
    if(intersect(s, p)) return true;
    Point a = s.ab  - p;
    Point b = s.to - p;
    if(a.y > b.y) swap(a, b);
    if(a.y < EPS && EPS <= b.y && cross(a, b) < EPS) in = !in;
  }
  return in;
}

D arg(Point a, Point b, Point c) {
  if(ccw(a, b, c) == ON_SEGMENT) return 0;
  if(ccw(a, b, c) == ONLINE_BACK) return PI;
  if(ccw(a, b, c) == ONLINE_FRONT) return 0;
  b = b - a;
  c = c - a;
  auto d = c.x * c.x + c.y * c.y;
  auto x = b.x * c.x + b.y * c.y;
  auto y = c.x * b.y - b.x * c.y;
  auto res = atan2(y / d, x / d);
  if(res < 0) res += 2 * PI;
  return res;
}

Segment rotate(Segment s, Point p, D a) {
  return Segment(p + rotate(s.ab - p, a), p + rotate(s.to - p, a));
}

pair<Point, D> touchpoint(auto ab, auto to, auto P) {
  if(ab == to) return {0, INF};

  vector<Point> v;
  Circle c(ab, distance(ab, to));
//   cout<<c.center<<c.radius<<endl;
  for(auto s: P) if(intersect(c, s)) for(auto cp: crosspoint(c, Line(s))) if(intersect(s, cp)) if(cp != ab) {
//     cout<<"   *"<<cp<<arg(ab,to,cp)<<endl;
    if(arg(ab, to, cp) > EPS) v.emplace_back(cp);
    else if(contain(P, ab + rotate(cp - ab, PI/100))) return {0, -INF};
  }
  for(auto s: P) if(contain(c, s.ab)) if(s.ab != ab) {
//     cout<<"   +"<<s.ab<<arg(ab,to,s.ab)<<endl;
    if(arg(ab, to, s.ab) > EPS) v.emplace_back(s.ab);
    else if(ccw(ab, s.ab, s.to) == CLOCKWISE) return {0, -INF};
  }

  auto p = min_element(begin(v), end(v), [&](auto lhs, auto rhs) {
    auto l = arg(ab, to, lhs);
    auto r = arg(ab, to, rhs);
    if(l != r) return l < r;
    return distance(ab, lhs) > distance(ab, rhs);
  });

  if(p == end(v)) return {0, INF};
  return {*p, arg(ab, to, *p)};
}

int main() {
  while(cin >> L >> R >> N, N) {
    vector<int> X(N), Y(N);
    for(auto i = 0; i < N; ++i) cin >> X[i] >> Y[i];

    P.clear();
    for(auto i = 0; i < N; ++i) P.emplace_back(X[i], Y[i], X[(i + 1) % N], Y[(i + 1) % N]);

    Segment bar(0, 0, 0, L);
    Point pivot(0, 0);
    D angle(2 * PI * R);

//     cout << setprecision(4) << fixed << bar.ab.x << ", " << bar.ab.y << ", " << bar.to.x << ", " << bar.to.y << endl;
    while(0 < angle) {
      Point p, q;
      D a, b;
      tie(p, a) = touchpoint(pivot, bar.ab, P);
      tie(q, b) = touchpoint(pivot, bar.to, P);
      if(b < a) {a = b; p = q;}
      assert(a != INF);
      if(a == -INF) break;
      a = min(angle, a);
      bar = rotate(bar, pivot, -a);
      angle -= a;
      pivot = p;
//     cout << setprecision(4) << fixed << pivot.x << ", " << pivot.y << endl;
//     cout << setprecision(4) << fixed << bar.ab.x << ", " << bar.ab.y << ", " << bar.to.x << ", " << bar.to.y << endl;
    }

    cout << setprecision(15) << fixed << bar.ab.x << " " << bar.ab.y << endl;
//     return 0;
  }
}

Measured memory_bytes: 3752