Problem:
Problem E: Legend of Storia

In Storia Kingdom, there is an artifact called "Perfect Sphere" made by a great meister Es. This is handed down for generations in the royal palace as a treasure. Es left a memo and filled mysterious values in it. Within achievements of researches, it has been revealed that the values denote coordinate values. However it is still unknown the definition of the coordinate system.

By the way, you are a person who lived in age of Es lived. The values which meister Es left are defined by following. Es set an moving object in the artifact sphere. Surprisingly, that is rigid body and perpetual organization. The object rotates inside the sphere and it is always touching the inside surface of the sphere. This value is a coordinate of the tangent point by the object and the sphere, but it is not a three dimensional value. The object is a plate and this is a simple polygon. Here, "simple" means "non self-intersected". This rotates while touching a great circle of the sphere. Here, assume that the great circle is a circle O centered in the origin in the xy plane. (It is two-dimensional Cartesian coordinate system, the direction of positive x-value is right and the direction of positive y-value is up). This plate touches the circle O with a single point at the beginning of the movement. And it rotates in counterclockwise as the current touching point is the rotation fulcrum. When another point X of the plate touches the circle O newly, the plate continue to rotate as described above, but in the next rotation, the rotation fulcrum point is changed. This will be the point X. If two or more points can be interpreted as the point X, the point X is a most distant point from the currently touching point X'. Here, that distance is the length of the arc of the circle O from the point X' to the point X in clockwise.

Es asked you, an excellent assistant, to write a program that enumerates Q tangent points (fulcrum points while the movement) by the plate and the circle O while the movement of the plate described above in the chronological order. Of course, one and the previous one must be distinct points. Following figures show you examples of the movement of the plate inside the circle O.

1

2

3

4

Input

Input consists of multiple datasets.

A dataset is given in a following format.

N R Q
x1 y1
x2 y2
...
xN yN

N, R, Q are integers that represent the number of points of the plate, the radius of the circle, and the number of points Es needs respectively.

Following N lines contain 2N integers that represent coordinates of the plate's points ( xk , yk ) in the circle.(1≤k≤N)

You can assume following conditions.

Points of the plate are given in counterclockwise.

No three points are co-linear.

N-1 points of the plate are given inside of the circle (distances between the center of the circle and these points are less than R). And 1 point is on the circle edge.

N=R=Q=0 shows the end of input.

Constraints

The number of datasets is less than or equal to 400.

3≤N≤25

1≤R≤1000

0≤Q≤100

Output

For each dataset, output (Px Py:real number) in Q in the following format.

Px1 Px1
Px2 Py2
...
PxN+1 PyN+1

These answers must satisfy |Txi-Pxi|≤0.0001 and |Tyi-Pyi|≤0.0001.

Here, Pxi, Pyi(1≤i≤Q) are your output and Txi,Tyi(1≤i≤Q) are judge's output.

Sample Input

4 10 8
0 -10
3 -7
0 -4
-3 -7
0 0 0

Output for the Sample Input

-4.146082488326 -9.100000000000
-7.545870128753 -6.562000000000
-9.587401146004 -2.842840000000
-9.903199956975 1.388031200000
-8.436422775690 5.369056784000
-5.451089494781 8.383652146880
-1.484560104812 9.889190123322
2.749190104024 9.614673877565

Solution in C++ (judge verdict: Wrong Answer)

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>


#define EPSILON 1e-9


class point_t;


class vector_t {
public:
  double x;
  double y;
  double z;
  
public:
  vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};
  
  vector_t(const point_t& p);

public:
  double operator[](int i) const {
    return (i == 0) ? x : (i == 1) ? y : z;
  };
  
  double& operator[](int i) {
    return (i == 0) ? x : (i == 1) ? y : z;
  };

public:
  vector_t operator-() const {
    return vector_t(-x, -y, -z);
  };
  
  vector_t operator+(const vector_t& v) const {
    return vector_t(x + v.x, y + v.y, z + v.z);
  };
  
  double operator*(const vector_t& v) const {
    return x * v.x + y * v.y + z * v.z;
  };
  
  vector_t operator*(double a) const {
    return vector_t(x * a, y * a, z * a);
  };
  
  vector_t operator/(double a) const {
    return vector_t(x / a, y / a, z / a);
  };
  
  vector_t operator^(const vector_t& v) const {
    return vector_t(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
  };
    
  vector_t operator-=(const vector_t& v) {
    x -= v.x;
    y -= v.y;
    z -= v.z;
    
    return *this;
  };

public:
  double length() const {
    return sqrt(*this * *this);
  };

  vector_t normal() const {
    return *this / length();
  };
};


class point_t {
public:
  double x;
  double y;
  double z;
  double w;

public:
  point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};

  point_t(const vector_t& v) : x(v.x), y(v.y), z(v.z), w(1) {};

public:
  double operator[](int i) const {
    return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w;
  };
  
  double& operator[](int i) {
    return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w;
  };
  
public:
  point_t operator+(const vector_t& v) const {
    return point_t(x + v.x, y + v.y, z + v.z);
  };

  vector_t operator-(const point_t& p) const {
    return vector_t(x - p.x, y - p.y, z - p.z);
  };

  point_t operator-() const {
    return point_t(-x, -y, -z, w);
  };
};


vector_t::vector_t(const point_t& p) : x(p.x / p.w), y(p.y / p.w), z(p.z / p.w)
{
}


class ccw_t : public std::unary_function<point_t, bool>
{
public:
  ccw_t(const point_t& p0, const point_t& p1) : p0_(p0), a_(p1 - p0) {};

public:
  bool operator()(const point_t& p) const {
    vector_t b(p - p0_);

    return (a_ ^ b).z > 0;
  };

private:
  point_t p0_;

  vector_t a_;
};


class reductor
{
public:
  reductor(double r) : r_(r) {};

public:
  std::vector<point_t> operator()(std::vector<point_t> points) const {
    int size = points.size();

    while (1) {
      points = reduce(points);

      if (size == points.size())
        break;
      
      size = points.size();
    }
    
    return points;
  };

private:
  std::vector<point_t> reduce(std::vector<point_t> points) const {
    int size = points.size();

    std::vector<bool> valid(size, true);

    for (int j = size - 1; j > 0; j --) {
      int i = (j + 1) % size;

      vector_t v(points[j] - points[i]);

      vector_t perp(vector_t(v.y, -v.x).normal());

      double l = v.length();

      double d = sqrt(r_ * r_ - l * l / 4);

      point_t o(points[i] + v / 2 + perp * d);

      for (int k = 0; k < size; k ++)
        if (k != i && k != j) {
          v = points[k] - o;

          if (v * v - r_ * r_ > -EPSILON) {
            valid[j] = false;

            break;
          }
        }

      if (! valid[j])
        break;
    }
    
    std::vector<point_t> pts;
    
    for (int i = 0; i < size; i ++)
      if (valid[i])
        pts.push_back(points[i]);

    return pts;
  };

private:
  double r_;
};


int main(int argc, char** argv)
{
  while (1) {
    int N, R, Q;

    std::cin >> N >> R >> Q;

    if (N == 0 && R == 0 && Q == 0)
      break;

    std::vector<point_t> points(N);

    for (int i = 0; i < N; i ++)
      std::cin >> points[i].x >> points[i].y;

    points = reductor(R)(points);

    N = points.size();

    std::vector<double> rs(N);

    for (int j = 0; j < N; j ++) {
      int k = (j + 1) % N;

      rs[j] = (points[k] - points[j]).length();
    }

    point_t p(points[0]);

    double r1 = R;

    for (int i = 0, j = N - 1; i < Q; i ++, j = (j - 1 + N) % N) {
      double r2 = rs[j];

      double a = - p.x / p.y;
      double b = (p.x * p.x + p.y * p.y + r1 * r1 - r2 * r2) / 2 / p.y;
      
      double A = a * a + 1;
      double B = a * b;
      double C = b * b - r1 * r1;
      
      double D = sqrt(B * B - A * C);
      
      point_t p1((- B + D) / A, a * (- B + D) / A + b);
      point_t p2((- B - D) / A, a * (- B - D) / A + b);

      p = ccw_t(point_t(), -p)(p1) ? p1 : p2;

      std::cout << std::setprecision(12) << p.x << ' ';
      std::cout << std::setprecision(12) << p.y << std::endl;
    }
  }

  return 0;
}