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 <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ESP (1e-13)
using namespace std;

//??§?¨????????§???????
typedef struct Point {
	double x; 
	double y;

	Point() { }

	Point(double x, double y) :x(x), y(y) { }

	Point operator+(const Point& p) {
		return Point(x + p.x, y + p.y);
	}

	Point operator-(const Point& p) {
		return Point(x - p.x, y - p.y);
	}

	Point operator*(const double& a) {
		return Point(x*a, y*a);
	}

	Point operator/(const double& a) {
		return Point(x / a, y / a);
	}

	Point operator=(const Point& p1) {
		return Point(p1.x,p1.y);
	}

};

//??´??§?????????????§???????
typedef Point Vector;

//??´???????§???????
 struct Line {
	Point p1, p2;
	Line() {}
	Line(const Point& a,const Point& b) : p1(a),p2(b) { }
};

 //??????????§???????
 typedef Line Segment;

 //???????§???????
 struct Circle {
	 Point c;
	 double r;
	 Circle(){ }
	 Circle(const Point& p,const double& r) : c(p),r(r) { }
 };

//2??????????????¢????±?????????¢??°
double abs(Point p1, Point p2) {
	double norm = (p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y);
	return sqrt(norm);
}

//????????¢??°
double product(Vector v1, Vector v2) {
	return v1.x*v2.x + v1.y*v2.y;
}

//????????¢??°
double cross(Vector p1, Vector p2) {
	return p1.x*p2.y - p1.y*p2.x;
}

//3??????????????¢???????±?????????¢??°
int ccw(Point p0, Point p1, Point p2) {
	Vector v0 = p1 - p0;
	Vector v1 = p2 - p0;
	if (cross(v0, v1) > ESP) return 1;   //p0,p1,p2??????????¨???????
	if (cross(v0, v1) < -ESP) return -1;   //p0,p1,p2???????¨???????
	if (product(v0, v1) < -ESP) return 2;  //p2,p0,p1????????§????????´??????
	if (abs(p0, p1) < abs(p0, p2)) return -2;  //p0,p1,p2????????§????????´??????
	return 0;   //p2?????????(p0,p1)???
}

//??????????????´????????????????°???±?????§?¨?????±?????????¢??°
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double x = abs(base, Point(0.0, 0.0))*abs(base, Point(0.0, 0.0));
	double r = product(p - s.p1, base) / x;
	return s.p1 + base*r;
}

//????????????????±??????¨??????????????????????§°????????§?¨?????±?????????¢??°
Point reflect(Segment s, Point p) {
	return (project(s, p) - p)*2.0 + p;
}


bool intersect(Point p0, Point p1, Point p2, Point p3) {
	return (ccw(p0, p1, p2)*ccw(p0, p1, p3) <= 0&&ccw(p2,p3,p0)*ccw(p2,p3,p1)<=0);
	//?????????????????????????????¶
}

//????????????????????£??????????????????????????¢??°
bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

//??´?????¨???????????¢????±?????????¢??°
double DistanceLP(Line l, Point p) {
	return abs(cross(l.p2 - l.p1, p - l.p1)/abs(l.p1,l.p2));
}

//????????¨???????????¢????±?????????¢??°
double DistanceSP(Segment s, Point p) {
	if (product(s.p2 - s.p1, p - s.p1) < -ESP) return abs(p, s.p1);
	if (product(s.p1 - s.p2, p - s.p2) < -ESP) return abs(p, s.p2);
	return DistanceLP(s, p);
}

//2??????????????¢????±?????????¢??°
double DistanceSS(Segment s1, Segment s2) {
	if (intersect(s1, s2)) return 0.0;
	return min(min(DistanceSP(s1, s2.p1), DistanceSP(s1,s2.p2)), min(DistanceSP(s2, s1.p1), DistanceSP(s2, s1.p2)));
}

//?????´???????\???¢????±?????????¢??°
Point CrossPoint(Line s1,Line s2) {
	double d1=DistanceLP(s2, s1.p1);
	double d2 = DistanceLP(s2, s1.p2);
	double t = d1 / (d1 + d2);
	return s1.p1 + (s1.p2 - s1.p1)*t;
}

//?????¨??´?????????????????????????????¢??°
bool intersect(Circle c, Line l) {
	return DistanceLP(l, c.c) < c.r;
}

//?????¨??´????????????????±?????????¢??°
pair<Point, Point> CrossPoints(Circle c, Line l) {
	Vector prpr = project(l, c.c);
	Vector hshs = (l.p2 - l.p1)/abs(l.p2 ,l.p1);
	double base = sqrt(c.r*c.r - abs(c.c, prpr)*abs(c.c, prpr));
	return make_pair(prpr - hshs*base, prpr + hshs*base);
}

//2??´??????????????¢???????±?????????¢??°???
   //??´?????????
bool isOrth(Vector a, Vector b) {
	return abs(product(a, b)) < ESP;
   }
bool isOrth(Point a1, Point a2, Point b1, Point b2) {
	return isOrth(a1 - a2, b1 - b2);
}
bool isOrth(Segment s1, Segment s2) {
	return isOrth(s1.p2, s1.p1, s2.p2, s2.p1);
}
    //????????????
bool isPara(Vector a, Vector b) {
	return abs(cross(a, b)) < ESP;
}
bool isPara(Point a1, Point a2, Point b1, Point b2) {
	return isPara(a1 - a2, b1 - b2);
}
bool isPara(Segment s1, Segment s2) {
	return isPara(s1.p2, s1.p1, s2.p2, s2.p1);
}


int main() {
	Circle c;
	int q;
	cin >> c.c.x; cin >> c.c.y; cin >> c.r;
	cin >> q;
	for (int i = 0;i < q;i++) {
		Line l;
		cin >> l.p1.x; cin >> l.p1.y;
		cin >> l.p2.x; cin >> l.p2.y;
		pair<Point, Point> crs = CrossPoints(c, l);
		cout << setprecision(12);
		if (abs(crs.first.x) < ESP) crs.first.x = 0;
		if (abs(crs.first.y) < ESP) crs.first.y = 0;
		if (abs(crs.second.x) < ESP) crs.second.x = 0;
		if (abs(crs.second.y) < ESP) crs.second.y = 0;

		if(crs.first.x<crs.second.x)
		cout << crs.first.x << " " << crs.first.y << " " << crs.second.x << " " << crs.second.y << endl;
		else if (crs.first.x>crs.second.x)
		cout << crs.second.x << " " << crs.second.y << " " << crs.first.x << " " << crs.first.y << endl;
		else if(crs.first.y<crs.second.y)
		cout << crs.first.x << " " << crs.first.y << " " << crs.second.x << " " << crs.second.y << endl;
		else
		cout << crs.second.x << " " << crs.second.y << " " << crs.first.x << " " << crs.first.y << endl;
	}
}