// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>
#include <array>

using namespace std;
using NUM = double;

static const NUM  EPS = 1e-10;

template<typename T>
struct Point {
	T x, y;
	Point<T> operator+(const Point<T>& rhs)const {
		Point<T> p;
		p.x = this->x + rhs.x;
		p.y = this->y + rhs.y;
		return p;
	}
	Point<T> operator-(const Point<T>& rhs)const {
		Point<T> p;
		p.x = this->x - rhs.x;
		p.y = this->y - rhs.y;
		return p;
	}
	Point<T> operator*(const T rhs) const {
		Point<T> p;
		p.x = this->x * rhs;
		p.y = this->y * rhs;
		return p;
	}
	Point<T> operator/(const T rhs) const {
		Point<T> p;
		p.x = this->x / rhs;
		p.y = this->y / rhs;
		return p;
	}
	Point<T> operator-() const {
		Point<T> p;
		p.x = this->x * -1.0;
		p.y = this->y * -1.0;
		return p;
	}
	static bool compByCrd(const Point<T>& p1, const Point<T>& p2) {
		if (abs(p1.x - p2.x) < EPS) return p1.y < p2.y;
		return p1.x < p2.x;
	}
};

template<typename T>
Point<T> operator*(const T val, const Point<T>& p)
{
	return p*val;
}

template<typename T>
struct Segment {
	Point<T> p1, p2;
};

template<typename T>
struct Circle {
	Point<T> center;
	T radius;
};

template<typename T>
bool isZero(const T val)
{
	return fabs(val) < 1e-10;
}

template<typename T>
T innerProduct(const Point<T>& p0, const Point<T>& p1)
{
	double x0 = p0.x;
	double y0 = p0.y;
	double x1 = p1.x;
	double y1 = p1.y;
	return x0 * x1 + y0 * y1;
}

template<typename T>
T outerProduct(const Point<T>& p0, const Point<T>& p1)
{
	double x0 = p0.x;
	double y0 = p0.y;
	double x1 = p1.x;
	double y1 = p1.y;
	return x0 * y1 - y0 * x1;
}

template<typename T>
T norm(const Point<T>& p)
{
	double x = p.x;
	double y = p.y;
	return x*x + y*y;
}

template<typename T>
T absolute(const Point<T>& p)
{
	return sqrt(norm(p));
}

template<typename T>
Point<T> unit(const Point<T>& p)
{
	return p / absolute(p);
}

template<typename T>
void readPoint(Point<T>& p)
{
	cin >> p.x;
	cin >> p.y;
}

template<typename T>
void readSegment(Segment<T>& s)
{
	cin >> s.p1.x;
	cin >> s.p1.y;
	cin >> s.p2.x;
	cin >> s.p2.y;
}

template<typename T>
void readCircle(Circle<T>& c)
{
	cin >> c.center.x;
	cin >> c.center.y;
	cin >> c.radius;
}

template<typename T>
void outputComponentesOfPoint(const Point<T>& p)
{
	cout << fixed;
	cout << setprecision(8) << p.x;
	cout << " ";
	cout << setprecision(8) << p.y;
	cout << endl;
}

template<typename T>
T getDistanceFromPointToLine(const Point<T>& p, const Segment<T>& s) {
	const Point<T> a = p - s.p1;
	const Point<T> b = s.p2 - s.p1;
	const T outer = outerProduct(a, b);
	return abs( outer / absolute(b) );
}

template<typename T>
Point<T> getIntersectionPointOfLineSegments(const Segment<T>& s1, const Segment<T>& s2)
{
	const T d1 = getDistanceFromPointToLine(s1.p1, s2);
	const T d2 = getDistanceFromPointToLine(s1.p2, s2);
	return s1.p1 + (s1.p2 - s1.p1) * (d1 / (d1 + d2));
}



//template<typename T>
//T distance(const Point<T>& p1, const Point<T>& p2)
//{
//	return absolute(p2 - p1);
//}
//

//template<typename T>
//T getDistanceFromPointToSegment(const Point<T>& p, const Segment<T>& s) {
//	const T zero = static_cast<T>(0);
//	const Point<T> a = p - s.p1;
//	const Point<T> b = s.p2 - s.p1;
//	const Point<T> c = p - s.p2;
//	const T innerAB = innerProduct(a, b);
//	const T innerc_b = innerProduct(c, -b);
//
//	if (innerAB < zero) {
//		return distance(p, s.p1);
//	}
//	else if (innerc_b < zero) {
//		return distance(p, s.p2);
//	}
//	else {
//		return fabs(outerProduct(a, b) / absolute(b) );
//	}
//}
//

//template<typename T>
//double getParameterOfProjectedPointToSegment(const Point<T>& p, const Segment<T>& s)
//{
//	const Point<T> a = p - s.p1;
//	const Point<T> b = s.p2 - s.p1;
//	const T normB = norm(b);
//	const T ab = innerProduct(a, b);
//	return ab / normB;
//}
//
//template<typename T>
//int getPositionOnSegment(const Point<T>& p, const Segment<T>& s)
//{
//	const T position = getParameterOfProjectedPointToSegment(p, s);
//	if (position < 0.0) {
//		return -1;
//	}
//	else if (1.0 < position) {
//		return 1;
//	}
//	else {
//		return 0;
//	}
//}

//static const int counter_clockwise = 2;
//static const int clockwise = -2;
//static const int online_back = -1;
//static const int online_front = 1;
//static const int onSegment = 0;
//
//template<typename T>
//int getPointPositionToSegment(const Point<T>& p, const Segment<T>& s)
//{
//	const Point<NUM> a = s.p2 - s.p1;
//	const Point<NUM> b = p - s.p1;
//	const NUM outer = outerProduct(a, b);
//	if (outer > EPS) return counter_clockwise;
//	if (outer < -EPS) return clockwise;
//	if (innerProduct(a, b) < -EPS) return online_back;
//	if (norm(b) > norm(a) + EPS) return online_front;
//	return onSegment;
//}
//
//template<typename T>
//bool intersects(const Segment<T>& s1, const Segment<T>& s2) {
//	return getPointPositionToSegment(s2.p1, s1) * getPointPositionToSegment(s2.p2, s1) <= 0
//		&& getPointPositionToSegment(s1.p1, s2) * getPointPositionToSegment(s1.p2, s2) <= 0;
//}

//
//template<typename T>
//T getDistanceFromSegmentToSegment(const Segment<T>& s1, const Segment<T>& s2) {
//	if (intersects(s1, s2)) {
//		return static_cast<T>(0.0);
//	}else{
//		return min(
//			min(getDistanceFromPointToSegment(s1.p1, s2), getDistanceFromPointToSegment(s1.p2, s2))
//			, min(getDistanceFromPointToSegment(s2.p1, s1), getDistanceFromPointToSegment(s2.p2, s1))
//		);
//	}
//}

//template<typename T>
//void projectPointToSegment(const Point<T>& p, const Segment<T>& s, Point<T>& foot, T& param)
//{
//	const Point<T> a = p - s.p1;
//	const Point<T> b = s.p2 - s.p1;
//	const T normB = norm(b);
//	const T ab = innerProduct(a, b);
//	param = ab / normB;
//	foot = s.p1 + (s.p2 - s.p1)*param;
//}

template<typename T>
Point<T> projectPointToSegment(const Point<T>& p, const Segment<T>& s)
{
	const Point<T> a = p - s.p1;
	const Point<T> b = s.p2 - s.p1;
	return s.p1 + (s.p2 - s.p1)*(innerProduct(a, b) /norm(b));
}

template<typename T>
array<Point<T>, 2> getIntersectionOfCircleAndLine(const Circle<T>& c, const Segment<T>& s)
{
	const T h = getDistanceFromPointToLine(c.center, s);
	// supposing c,radius >= h
	const T d = sqrt(c.radius*c.radius - h*h);
	const Point<T> v = unit(s.p2 - s.p1);
	const Point<T> foot = projectPointToSegment(c.center, s);
	
	array<Point<T>, 2> ret;
	ret.at(0) = foot + v*d;
	ret.at(1) = foot - v*d;
	return ret;
}

int main()
{
	Circle<NUM> c;
	readCircle(c);
	int q; cin >> q;
	for (int i = 0; i != q; ++i) {
		Segment<NUM> s;
		readSegment(s);
		array<Point<NUM>, 2> points = getIntersectionOfCircleAndLine(c, s);
		sort(points.begin(), points.end(), Point<NUM>::compByCrd);
		cout << fixed;
		cout << setprecision(8) << points.at(0).x;
		cout << " ";
		cout << setprecision(8) << points.at(0).y;
		cout << " ";
		cout << setprecision(8) << points.at(1).x;
		cout << " ";
		cout << setprecision(8) << points.at(1).y;
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3288