#include<iostream>
#include<iomanip>
#include<algorithm>
#include<fstream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#define EPS (1e-7)
#define equals(a, b) (fabs((a) - (b)) < EPS )
//#define cout fout
//#define cin fin
#define CCW 1
#define YCW -1
#define ONB 3
#define ONF 4
#define ONS 0
using namespace std;

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 a) {
		return Point(a * x, a * y);
	}
	Point operator / (double a) {
		return Point(x / a, y / a);
	}

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

	bool operator < (const Point &p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

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

typedef Point Vector;

#ifdef cin
ifstream fin("CGL_1_C-in29.txt");
#endif

#ifdef cout
ofstream fout("out.txt");
#endif

double dot(Vector a, Vector b);
double cross(Vector a, Vector b);
double getDistanceSP(Point p, Point p1, Point p2);
double angle(Vector a, Vector b);
bool doIntersect(Point p1, Point p2, Point p3, Point p4);
double getDistanceSS(Point p1, Point p2, Point p3, Point p4);
int clockwise(Point p0, Point p1, Point p2);
Point crossPoint(Point p1, Point p2, Point p3, Point p4);
pair<Point, Point> crossPoint(Point p1, Point p2, Point center, double r);
Vector rotateVector(Vector v, double angle); //rad
Point project(Point p, Point p1, Point p2);

int main() {
    int i, q;
	double cx, x1, x2, cy, y1, y2, r;
	
	cin >> cx >> cy >> r >> q;
	Point center(cx, cy);
	for (i = 0; i < q; i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		Point p1(x1, y1), p2(x2, y2);
		pair<Point, Point> ans = crossPoint(p1, p2, center, r);
		//cout << setprecision(15) << ans.first.x << " " << ans.first.y << " " << ans.second.x << " " << ans.second.y << endl;
		printf("%.9f %.9f %.9f %.9f\n", ans.first.x, ans.first.y, ans.second.x, ans.second.y);
	}
#ifdef cin
	fin.close();
#endif

#ifdef cout
	fout.close();
#endif
	return 0;
}

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

double getDistanceSP(Point p, Point p1, Point p2) {
	if (dot(p - p1, p2 - p1) < 0.0)return (p - p1).abs();
	else if (dot(p - p2, p1 - p2) < 0.0)return (p - p2).abs();
	else return  fabs(cross(p2 - p1, p - p1)) / (p2 - p1).abs();
}


double angle(Vector a, Vector b) {
	if (equals(dot(a, b), a.abs() * b.abs()))return 0.0;
	else if (equals(dot(a, b), (-1) * a.abs() * b.abs()))return M_PI;
	if (cross(a, b) > 0.0)return acos(dot(a, b) / a.abs() / b.abs());
	else return (-1) * acos(dot(a, b) / a.abs() / b.abs());
}

bool doIntersect(Point p1, Point p2, Point p3, Point p4) {
	if (clockwise(p1, p2, p3) *  clockwise(p1, p2, p4) * clockwise(p3, p4, p1) * clockwise(p3, p4, p1) == 0) {
		return true;
	} else if (-1 <= clockwise(p1, p2, p3) * clockwise(p1, p2, p4) && clockwise(p1, p2, p3) * clockwise(p1, p2, p4) <= 0 && -1 <= clockwise(p3, p4, p1) * clockwise(p3, p4, p2) && clockwise(p3, p4, p1) * clockwise(p3, p4, p2) <= 0) {
		return true;
	} else {
		return false;
	}
}

double getDistanceSS(Point p1, Point p2, Point p3, Point p4) {
	if (doIntersect(p1, p2, p3, p4))return 0;
	else return min({ getDistanceSP(p4, p1, p2), getDistanceSP(p3, p1, p2), getDistanceSP(p1, p3, p4), getDistanceSP(p2, p3, p4) });
}

int clockwise(Point p0, Point p1, Point p2) {
	if (p2 == p0 || p2 == p1) {
		//cout << "ON_SEGMENT" << endl;
		return ONS;
	} else if (angle(p1 - p0, p2 - p0) == 0.0) {
		if ((p1 - p0).norm() < (p2 - p0).norm()) {
			//cout << "ONLINE_FRONT" << endl;
			return ONF;
		} else {
			//cout << "ON_SEGMENT" << endl;
			return ONS;
		}
	} else if(angle(p1 - p0, p2 - p0) == M_PI){
		//cout << "ONLINE_BACK" << endl;
		return ONB;
	} else {
		if (angle(p1 - p0, p2 - p0) > 0.0) {
			//cout << "COUNTER_CLOCKWISE" << endl;
			return CCW;
		} else {
			//cout << "CLOCKWISE" << endl;
			return YCW;
		}
	}
}

Point crossPoint(Point p1, Point p2, Point p3, Point p4) {
	double d1, d2, t;
	d1 = fabs(cross(p2 - p1, p3 - p1) / (p2 - p1).norm());
	d2 = fabs(cross(p2 - p1, p4 - p1) / (p2 - p1).norm());
	t = d1 / (d1 + d2);
	return (p3 + (p4 - p3) * t);
}

pair<Point, Point> crossPoint(Point p1, Point p2, Point center, double r) {
	Vector pr = project(center, p1, p2) - center;
	double base = sqrt(r * r - pr.norm());

	Vector ans1 = center + pr + (p2 - p1) / (p2 - p1).abs() * base;
	Vector ans2 = center + pr - (p2 - p1) / (p2 - p1).abs() * base;
	
	if (ans1 < ans2) {
		return make_pair(ans1, ans2);
	} else {
		return make_pair(ans2, ans1);
	}

}

Vector rotateVector(Vector v, double angle) {
	Vector ans(v.x * cos(angle) - v.y * sin(angle), v.x * sin(angle) + v.y * cos(angle));
	return ans;
}

Point project(Point p, Point p1, Point p2) {
	Vector hypo = p - p1, base = p2 - p1;
	return (p1 + base * dot(hypo, base) / base.norm());
}

Measured memory_bytes: 3204