Problem: For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.

Constraints

* $p1$ and $p2$ are different
* The circle and line have at least one cross point
* $1 \leq q \leq 1,000$
* $-10,000 \leq cx, cy, x1, y1, x2, y2 \leq 10,000$
* $1 \leq r \leq 10,000$

Input

The input is given in the following format.

$cx\; cy\; r$
$q$
$Line_1$
$Line_2$
:
$Line_q$


In the first line, the center coordinate of the circle and its radius are given by $cx$, $cy$ and $r$. In the second line, the number of queries $q$ is given.

In the following $q$ lines, as queries, $Line_i$ are given ($1 \leq i \leq q$) in the following format.

$x_1\; y_1\; x_2\; y_2$

Each line is represented by two points $p1$ and $p2$ which the line crosses. The coordinate of $p1$ and $p2$ are given by ($x1$, $y1$) and ($x2$, $y2$) respectively. All input values are given in integers.

Output

For each query, print the coordinates of the cross points in the following rules.

* If there is one cross point, print two coordinates with the same values.
* Print the coordinate with smaller $x$ first. In case of a tie, print the coordinate with smaller $y$ first.



The output values should be in a decimal fraction with an error less than 0.000001.

Example

Input

2 1 1
2
0 1 4 1
3 0 3 3


Output

1.00000000 1.00000000 3.00000000 1.00000000
3.00000000 1.00000000 3.00000000 1.00000000

Solution (in CPP):

Solution:
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs(a - b) < EPS)

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);
    }

    double norm(){
        return x * x + y * y;
    }

    double abs(){
        return sqrt(norm());
    }

    bool operator == (const Point &p) const{
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

class Seg{
public:
    Point p1;
    Point p2;
    Seg(Point p1_, Point p2_){
        p1 = p1_;
        p2 = p2_;
    }
};

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;
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
}

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
}
;
double getCos(Vector a, Vector b){
    return dot(a, b) / (a.abs() * b.abs());
}

double dist(Point p1, Point p2){
    return sqrt(pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2));
}

Point project(Seg s, Point p0){
    if(s.p1 == p0){
        return p0;
    }
    if(s.p2 == p0){
        return p0;
    }
    return s.p1 + (s.p2 - s.p1) / (s.p2 - s.p1).abs() * (p0 - s.p1).abs() * getCos(s.p2 - s.p1, p0 - s.p1);
}

Point reflect(Seg s, Point p0){
    Point p = project(s, p0);
    return p0 + (p - p0) * 2;
}


#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0

int counterClockwise(Point p0, Point p1, Point p2){
    Vector v1 = p1 - p0;
    Vector v2 = p2 - p0;
    if(cross(v1, v2) > EPS) return COUNTER_CLOCKWISE;
    if(cross(v1, v2) < -EPS) return CLOCKWISE;
    if(dot(v1, v2) < -EPS) return ONLINE_BACK;
    if(v1.norm() < v2.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Seg s1, Seg s2){
    int t1 = counterClockwise(s1.p1, s1.p2, s2.p1);
    int t2 = counterClockwise(s1.p1, s1.p2, s2.p2);
    int t3 = counterClockwise(s2.p1, s2.p2, s1.p1);
    int t4 = counterClockwise(s2.p1, s2.p2, s1.p2);
    if(t1 * t2 <= 0){
        if(t3 * t4 <= 0){
            return true;
        }
    }
    return false;
}

double getDistanceLP(Seg s, Point p0){
    return (project(s, p0) - p0).abs();
}

double getDistanceSP(Seg s, Point p0){
    if(dot(s.p2 - s.p1, p0 - s.p1) < 0.0) return (p0 - s.p1).abs();
    if(dot(s.p1 - s.p2, p0 - s.p2) < 0.0) return (p0 - s.p2).abs();
    return (project(s, p0) -  p0).abs();
}

double getDistance(Seg s1, Seg s2){
    if(intersect(s1, s2)){
        return 0.0;
    }
    return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),
                min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}

Point crossPoint(Seg s1, Seg s2){
    double d1 = getDistanceLP(s2, s1.p1);
    double d2 = getDistanceLP(s2, s1.p2);

    return (s1.p2 * d1 + s1.p1 * d2) / (d1 + d2);
}

pair<Point, Point> getCrossPoints(Point x, double r, Seg s){
    double d1 = getDistanceLP(s, x);
    double d2 = sqrt(pow(r, 2) - pow(d1, 2));

    Point p1 = project(s, x);
    Vector v1 = s.p2 - s.p1;

    Point cp1 = p1 + v1 / v1.abs() * d2;
    Point cp2 = p1 - v1 / v1.abs() * d2;

    if(cp1.x < cp2.x){
        return make_pair(cp1, cp2);
    }else if(cp1.x > cp2.x){
        return make_pair(cp2, cp1);
    }else{
        return cp1.y < cp2.y ? make_pair(cp1, cp2) : make_pair(cp2, cp1);
    }

}

int main(){
    int cx, cy, r, q;
    scanf("%d", &cx);
    scanf("%d", &cy);
    scanf("%d", &r);
    scanf("%d", &q);

    Point x = Point(cx, cy);

    for(int i = 0; i < q; i++){
        int xp0, yp0, xp1, yp1;
        scanf("%d", &xp0);
        scanf("%d", &yp0);
        scanf("%d", &xp1);
        scanf("%d", &yp1);

        pair<Point, Point> ps = getCrossPoints(x, r, Seg(Point(xp0, yp0), Point(xp1, yp1)));

        printf("%.10f %.10f %.10f %.10f\n", ps.first.x, ps.first.y, ps.second.x, ps.second.y);
    }

}