Let's think about a bar rotating clockwise as if it were a twirling baton moving on a planar surface surrounded by a polygonal wall (see Figure 1).

<image>


Figure 1. A bar rotating in a polygon

Initially, an end of the bar (called "end A") is at (0,0), and the other end (called "end B") is at (0,L) where L is the length of the bar. Initially, the bar is touching the wall only at the end A.

The bar turns fixing a touching point as the center. The center changes as a new point touches the wall.

Your task is to calculate the coordinates of the end A when the bar has fully turned by the given count R.

<image>


Figure 2. Examples of turning bars

In Figure 2, some examples are shown. In cases (D) and (E), the bar is stuck prematurely (cannot rotate clockwise anymore with any point touching the wall as the center) before R rotations. In such cases, you should answer the coordinates of the end A in that (stuck) position.

You can assume the following:

> When the bar's length L changes by ε (|ε| < 0.00001), the final (x,y) coordinates will not change more than 0.0005.

Input

The input consists of multiple datasets. The number of datasets is no more than 100. The end of the input is represented by "0 0 0".

The format of each dataset is as follows:


L R N
X1 Y1
X2 Y2
...
XN YN


L is the length of the bar. The bar rotates 2π× R radians (if it is not stuck prematurely). N is the number of vertices which make the polygon.

The vertices of the polygon are arranged in a counter-clockwise order. You may assume that the polygon is simple, that is, its border never crosses or touches itself.

N, Xi and Yi are integer numbers; R and L are decimal fractions. Ranges of those values are as follows:


1.0 ≤ L ≤ 500.0,
1.0 ≤ R ≤ 10.0,
3 ≤ N ≤ 100,
-1000 ≤ Xi ≤ 1000,
-1000 ≤ Yi ≤ 1000,



X1 ≤ -1,  Y1 = 0,
X2 ≥ 1,  Y2 = 0.


Output

For each dataset, print one line containing x- and y-coordinates of the final position of the end A, separated by a space. The value may contain an error less than or equal to 0.001. You may print any number of digits after the decimal point.

Sample Input


4.0 2.0 8
-1 0
5 0
5 -2
7 -2
7 0
18 0
18 6
-1 6
4.0 2.0 4
-1 0
10 0
10 12
-1 12
4.0 1.0 7
-1 0
2 0
-1 -3
-1 -8
6 -8
6 6
-1 6
4.0 2.0 6
-1 0
10 0
10 3
7 3
7 5
-1 5
5.0 2.0 6
-1 0
2 0
2 -4
6 -4
6 6
-1 6
6.0 1.0 8
-1 0
8 0
7 2
9 2
8 4
11 4
11 12
-1 12
0 0 0


Output for the Sample Input


16.0 0.0
9.999999999999998 7.4641016151377535
0.585786437626906 -5.414213562373095
8.0 0.0
6.0 0.0
9.52786404500042 4.0


Note that the above sample input corresponds to the cases in Figure 2. For convenience, in Figure 3, we will show an animation and corresponding photographic playback for the case (C).

<image>
<image> | <image> | <image> | <image> | <image> | <image> | <image> | <image> | <image>
---|---|---|---|---|---|---|---|---

Figure 3. Animation and photographic playback for case (C)





Example

Input

4.0 2.0 8
-1 0
5 0
5 -2
7 -2
7 0
18 0
18 6
-1 6
4.0 2.0 4
-1 0
10 0
10 12
-1 12
4.0 1.0 7
-1 0
2 0
-1 -3
-1 -8
6 -8
6 6
-1 6
4.0 2.0 6
-1 0
10 0
10 3
7 3
7 5
-1 5
5.0 2.0 6
-1 0
2 0
2 -4
6 -4
6 6
-1 6
6.0 1.0 8
-1 0
8 0
7 2
9 2
8 4
11 4
11 12
-1 12
0 0 0


Output

16.0 0.0
9.999999999999998 7.4641016151377535
0.585786437626906 -5.414213562373095
8.0 0.0
6.0 0.0
9.52786404500042 4.0
#include <bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

const double INF = 1e+8;
const double EPS = 1e-8;

struct Circle{
  P c;
  double r;
  Circle(P c=P(0,0), double r=0):c(c),r(r){}
};

typedef Circle Side;

bool equal(double a, double b){ return fabs(a-b) < EPS;}
bool equal(P a, P b){ return fabs(real(a-b)) < EPS && fabs(imag(a-b)) < EPS;}

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,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;
}

bool isIntersectSP(L s, P p){ 
  return abs(s.first-p) + abs(s.second-p) - abs(s.second-s.first) < EPS; 
}

bool isIntersect(L s1, L s2){
  
  //ccw ??????????????????????????¨, ????????????????????´?????????????????¨??????????????????????????????
  if(max(real(s1.first), real(s1.second)) + EPS < min(real(s2.first), real(s2.second)) ||
     max(imag(s1.first), imag(s1.second)) + EPS < min(imag(s2.first), imag(s2.second)) ||
     max(real(s2.first), real(s2.second)) + EPS < min(real(s1.first), real(s1.second)) ||
     max(imag(s2.first), imag(s2.second)) + EPS < min(imag(s1.first), imag(s1.second))) return false;

  if(isIntersectSP(s1, s2.first) || isIntersectSP(s1, s2.second) || isIntersectSP(s2, s1.first) || isIntersectSP(s2, s1.second)) return false;

  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

vector<P> getIntersectCS(Circle c, L s){
  vector<P> res;
  P h = proj(c.c, s);
  double d = abs(c.c - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isIntersectSP(s,h)) res.push_back(h);
  }
  else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isIntersectSP(s, h+v)) res.push_back(h+v);
    if(isIntersectSP(s, h-v)) res.push_back(h-v);
  }
  return res;
}

enum {OUT, BORDER, IN};
int contains(vector<P> v, P p){ 
  bool in = false; 
  for(int i=0;i<v.size();i++){ 
    P a = v[i] - p; 
    P b = v[(i+1)%v.size()] - p; 
    if(imag(a) > imag(b)) swap(a,b); 
    if(imag(a) <= EPS && EPS < imag(b)) 
      if(cross(a,b) < -EPS) in = !in; 
    if(equal(cross(a,b), 0.0) && dot(a,b) < EPS) return 1; 
  } 
  return in ? 2 : 0; 
}


double l, r;
int n;
vector<P> v;

bool cross_wall(L l){
  for(int i=0;i<n;i++){
    if(isIntersect(l, L(v[i], v[(i+1)%n]))) return true;
  }
  return contains(v, (l.first + l.second) / 2.0) == OUT;
}

double calc_arg(Circle cir, P next, P cen){
  P prev = cir.c;
  double a1 = arg(prev - cen);
  double a2 = arg(next - cen);
  if(a1 < a2 + EPS) a1 += 2.0 * M_PI;
  return a1 - a2;
}

P solve(){
  Side side[2] = {Circle(P(0,0), 0), Circle(P(0,l), l)};
  double theta = M_PI / 2.0;
  P cen = P(0,0), prev_cen = P(0,0);

  r *= 2.0 * M_PI;
  r = M_PI / 2.0 - r;

  while(r < theta - EPS){
    P next;
    double move = theta - r;
    //cout << theta * 180.0 / M_PI << " - " << r * 180.0 / M_PI << " = " << move * 180.0 / M_PI << endl;
    for(int i=0;i<2;i++){
      double len = 0;
      if(equal(side[i].r, 0.0)) continue;

      // ?§???¨??¶???????????´???
      for(int j=0;j<n;j++){
        if(abs(cen - v[j]) > side[i].r + EPS || cross_wall(L(cen, v[j])) || isIntersectSP(L(side[0].c, side[1].c), v[j]) || equal(v[j], prev_cen) || equal(v[j], cen)) continue;
        double res_arg = calc_arg(side[i], v[j], cen);
        if(move < res_arg - EPS || equal(move, res_arg) && len > abs(cen - v[j]) - EPS) continue;
        move = res_arg;
        len = abs(cen - v[j]);
        next = v[j];
      }

      // ?????¨??¶???????????´???
      for(int j=0;j<n;j++){
        vector<P> cs = getIntersectCS(Circle(cen, side[i].r), L(v[j], v[(j+1)%n]));
        for(int k=0;k<cs.size();k++){
          if(cross_wall(L(cen, cs[k])) || equal(cs[k], prev_cen)) continue;
          double res_arg = calc_arg(side[i], cs[k], cen);
          if(move < res_arg - EPS || equal(move, res_arg) && len > abs(cen - cs[k]) - EPS) continue;
          move = res_arg;
          len = abs(cen - cs[k]);
          next = cs[k];
        }
      }

    }

    //cout << "move = " << move * 180.0 / M_PI << ", rem = " << (theta - r) * 180.0 / M_PI << endl;

    if(equal(move, 0.0)) return side[0].c;
    for(int i=0;i<2;i++){
      P pp = rotate(side[i].c - cen, -move/2.0) + cen;
      if(side[i].r > EPS && contains(v, pp) == OUT) return side[0].c;
    }

    //cout << side[0].c << ',' << side[1].c << ',' << cen << " -> ";

    for(int i=0;i<2;i++) {
      side[i].c = rotate(side[i].c - cen, -move) + cen;
      side[i].r = abs(next - side[i].c);
    }
    prev_cen = cen;
    cen = next;
    theta -= move;
    //cout << side[0].c << ',' << side[1].c << ',' << cen << endl;
  }


  return side[0].c;
}

int main(){
  double x, y;
  while(cin >> l >> r >> n && n){
    v.clear();
    for(int i=0;i<n;i++){
      cin >> x >> y;
      v.push_back(P(x, y));
    }
    P ans = solve();
    printf("%.10f %.10f\n", real(ans), imag(ans));
  }
}