#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0.0,double y = 0.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 lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	Point neg(){
		return Point(-x,-y);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point &p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point &p)const
	{
		if(abs(x - p.x) < EPS) return y < p.y;
		else return x < p.x;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(Point p1 = Point(),Point p2 = Point()): p1(p1),p2(p2) {}
};
typedef Segment Line;
struct Circle{
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0): c(c),r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector a,Vector b){
	return a.x * b.x + a.y * b.y;
}
double det(Vector a,Vector b){
	return a.x * b.y - b.x * a.y;
}
bool vertical(Line l1,Line l2){
	return abs(dot(l1.p2 - l1.p1,l2.p2 - l2.p1)) < EPS;
}
bool parallel(Line l1,Line l2){
	return abs(det(l1.p2 - l1.p1,l2.p2 - l2.p1)) < EPS;
}
Point proj(Point p,Line l){
	Vector a = l.p2 - l.p1;
	double r = dot(a,p - l.p1) / a.norm();
	return l.p1 + a * r;
}
Point ref(Point p,Line l){
	Point A = proj(p,l);
	return A + (A - p);
}
int ccw(Segment/*Directed Segment*/ s,Point p){//
	Vector a = s.p2 - s.p1,b = p - s.p1;
	if(det(a,b) > EPS) return 1;//COUNTER_CLOCKWISE
	else if(det(a,b) < -EPS) return -1;//CLOCKWISE
	else if(dot(a,b) < -EPS) return 2;//ONLINE_BACK
	else if(a.norm() < b.norm() - EPS) return -2;//ONLINE_FRONT
	else return 0;//ON_SEGMENT
}
bool intersect(Segment s1,Segment s2){
	return ccw(s1,s2.p1) * ccw(s1,s2.p2) <= 0 && ccw(s2,s1.p1) * ccw(s2,s1.p2) <= 0;
}
double disSP(Segment s,Point p){
	Vector a = s.p2 - s.p1;
	if(dot(a,p - s.p1) < EPS) return (p - s.p1).abs_();
	if(dot(a.neg(),p - s.p2) < EPS) return (p - s.p2).abs_();
	return abs(det(a,p - s.p1) / a.abs_());
}
double disSS(Segment s1,Segment s2){
	if(intersect(s1,s2)) return 0;
	return min(min(disSP(s1,s2.p1),disSP(s1,s2.p2)),min(disSP(s2,s1.p1),disSP(s2,s1.p2)));
}
Point crossSS(Segment s1,Segment s2){//make sure s1 intersect s2!
	Vector a = s2.p2 - s2.p1;
	double d1 = abs(det(a,s1.p1 - s2.p1));
	double d2 = abs(det(a,s1.p2 - s2.p1));
	return s1.p1 + (s1.p2 - s1.p1) * (d1 / (d1 + d2));
}
vector <Point> crossCL(Circle o,Line l){
	Point A = proj(o.c,l);
	Vector a = l.p2 - l.p1, e = a / a.abs_();
	double AP = sqrt(o.r * o.r - (A - o.c).norm());
	vector <Point> res;
	res.push_back(A + e * AP);
	res.push_back(A - e * AP);
	return res;
}
int main(){
	Circle o; Line l;
	scanf("%lf%lf%lf",&o.c.x,&o.c.y,&o.r);
	int t;
	scanf("%d",&t);
	while(t--){
		scanf("%lf%lf%lf%lf",&l.p1.x,&l.p1.y,&l.p2.x,&l.p2.y);
		vector <Point> ans = crossCL(o,l);
		sort(ans.begin(),ans.end());
		for(int i=0;i<(int)ans.size();i++){
			printf("%.10f %.10f%c",ans[i].x,ans[i].y,i == (int)ans.size() - 1 ? '\n' : ' ');
		}
	}
	return 0;
}



Measured memory_bytes: 3240