////////////////////////////////////////
///  tu3 pro-con template            ///
////////////////////////////////////////
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
#include <valarray>
using namespace std;

//// MACRO ////
#define countof(a) (sizeof(a)/sizeof(a[0]))

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define RFOR(i,s,n) for (int i = (n)-1; i >= (s); i--)
#define pos(c,i) c.being() + (i)
#define allof(c) c.begin(), c.end()
#define aallof(a) a, countof(a)
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define apartof(a,i,n) a + (i), a + (i) + (n)
//#define long long long

#define EPS 1e-9
#define INF (1L << 24)
#define LINF (1LL << 60)

#define PREDICATE(t,a,...) [&](const t & a) -> bool { return __VA_ARGS__; }
#define COMPARISON_T(t) bool(*)(const t &, const t &)
#define COMPARISON(t,a,b,...) [&](const t & a, const t & b) -> bool { return __VA_ARGS__; }
#define CONVERTER(TSrc,t,TDest,...) [&](const TSrc &t)->TDest { return __VA_ARGS__; }

inline int sign(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
inline bool inRange(int val, int min, int max) { return val >= min && val < max; }
inline bool inRange(double val, double min, double max) { return val - min > -EPS && val - max < EPS; }
inline bool inRange(int x, int y, int W, int H) { return x >= 0 && x < W && y >= 0 && y < H; } // W,H????????????
template <class T> struct vevector : public vector<vector<T>> { vevector(int n = 0, int m = 0, const T &initial = T()) : vector<vector<T>>(n, vector<T>(m, initial)) { } };
template <class T> struct vevevector : public vector<vevector<T>> { vevevector(int n = 0, int m = 0, int l = 0, const T &initial = T()) : vector<vevector<T>>(n, vevector<T>(m, l, initial)) { } };
template <class T> struct vevevevector : public vector<vevevector<T>> { vevevevector(int n = 0, int m = 0, int l = 0, int k = 0, const T &initial = T()) : vector<vevevector<T>>(n, vevevector<T>(m, l, k, initial)) { } };

//// i/o helper ////

#ifdef _DEBUG
#define DEBUG WRITE
inline void readfrom(string filename) { freopen(filename.c_str(), "r", stdin); }
inline void writeto(string filename) { freopen(filename.c_str(), "w", stdout); }
#else
#define DEBUG(...)
inline void readfrom(...) { }
inline void writeto(...) { }
#endif
#ifdef colored_cout
#  define cout colored_cout
#  define endl colored_endl
#endif


template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i, n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i, n) v.push_back(read<T>(m)); return v; }
template <class T> vector<T> readjag() { return read<T>(read<int>()); }
template <class T> vevector<T> readjag(int n) { vevector<T> v; REP(i, n) v.push_back(readjag<T>()); return v; }

template <class T1, class T2> inline istream & operator >> (istream & in, pair<T1, T2> &p) { in >> p.first >> p.second; return in; }
template <class T1, class T2> inline ostream & operator << (ostream &out, const pair<T1, T2> &p) { out << p.first << " " << p.second; return out; }
template <class T> inline ostream & operator << (ostream &out, const vector<T> &v)
{
	ostringstream ss;
	for (auto x : v) ss << x << " ";
	auto s = ss.str();
	out << s.substr(0, s.length() - 1);
	return out;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
struct _Writer { bool f; _Writer() : f(false) { } template <class T> _Writer operator ,(const T &rhs) { cout << (f ? " " : "") << rhs; f = true; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define WRITE(...) _Writer(), __VA_ARGS__; cout << endl


//// start up ////
void solve();

int main()
{
	solve();
	return 0;
}

//// geometry ////

//// 2D geometry ////

// ?????¢?????????????????????????????¢?????????????????????
struct P2
{
	double x, y;
	P2(double x = 0, double y = 0) : x(x), y(y) { }
	P2(complex<double> c) : x(c.real()), y(c.imag()) { }
	P2 operator +() const { return *this; }
	P2 operator +(const P2 &_) const { return P2(x + _.x, y + _.y); }
	P2 operator -() const { return P2(-x, -y); }
	P2 operator -(const P2 &_) const { return *this + -_; }
	P2 operator *(double _) const { return P2(x*_, y*_); }
	P2 operator /(double _) const { return P2(x / _, y / _); }
	double dot(const P2 &_) const { return x*_.x + y*_.y; } // ??????
	double cross(const P2 &_) const { return x*_.y - y*_.x; } // ??????
	double sqlength() const { return x*x + y*y; } // ????????????
	double length() const { return sqrt(sqlength()); } // ??????
	P2 orthogonal() const { return P2(y, -x); }
	P2 direction() const { return *this / length(); } // ??????????????????
	double arg() const { return atan2(y, x); }
	static P2 polar(double length, double theta) { return P2(std::polar(length, theta)); }
};
inline istream & operator>>(istream & in, P2 & p) { in >> p.x >> p.y; return in; }
inline ostream & operator<<(ostream & out, const P2 & p) { out << setprecision(16) << p.x << ' ' << p.y; return out; }
inline double abs(P2 p2) { return p2.length(); } // ??????
inline P2 orthogonal(P2 p) { return p.orthogonal(); } // ?????´
inline complex<double> orthogonal(complex<double> c) { return  c * complex<double>(0, 1); } // ?????´

																							// a,b ?????? ???????????? d ????????¢????????????a??¨b????????¨????????????????????????
inline pair<P2, P2> get_same_distance_points(P2 a, P2 b, double d)
{
	assert(abs(a - b) <= 2 * d + EPS);
	auto v = (a + b) / 2.0 - a; // a ?????? a??¨b?????????
	auto vl = abs(v);
	auto wl = sqrt(d*d - vl*vl); // ??´???V?????§??????
	auto w = orthogonal(v) * (wl / vl); // ??´???V
	return make_pair(a + v + w, a + v - w);
}

// a ?????? b ???????????£??????c????????????????????????
inline int clockwise(P2 a, P2 b, P2 c)
{
	const P2 u = b - a, v = c - a;
	if (u.cross(v) > EPS) { return 1; }
	if (u.cross(v) < -EPS) { return -1; }
	if (u.dot(v) < -EPS) { return -1; }
	if (u.sqlength() < v.sqlength() - EPS) { return 1; }
	return 0;
}

/// ??´???
struct Line
{
	P2 p, d; // ?§?????????????
	explicit Line(P2 pos = P2(), P2 dir = P2()) : p(pos), d(dir) { }
	static Line FromPD(P2 pos, P2 dir) { return Line(pos, dir); }
	static Line From2Point(P2 a, P2 b) { return Line(a, b - a); }
};

/// ??????
struct LineSeg
{
	P2 p, d; // ?§???????????????§??????
	explicit LineSeg(P2 pos = P2(), P2 dir = P2()) : p(pos), d(dir) { }
	static LineSeg FromPD(P2 pos, P2 dir) { return LineSeg(pos, dir); }
	static LineSeg From2Point(P2 a, P2 b) { return LineSeg(a, b - a); }
	operator Line() { return Line(p, d); }
};

// ????????????a???????????????b???????°???±
inline P2 projective(P2 a, P2 b)
{
	return b * (a.dot(b) / b.sqlength());
}

// ??????????¶?
inline P2 perpendicular_foot(P2 a, Line b)
{
	Line l = Line(b.p - a, b.d);
	return a + l.p - projective(l.p, l.d);
}

// ??????a???b???????°???±
inline LineSeg projective(LineSeg a, Line b)
{
	return LineSeg(perpendicular_foot(a.p, b), projective(a.d, b.d));
}

// ??????
inline P2 crossPoint(Line a, Line b) { return a.p + a.d * (b.d.cross(b.p - a.p) / b.d.cross(a.d)); }

// ?????¬??????
inline bool contains(LineSeg a, P2 p) { return abs(a.p - p) + abs(a.p + a.d - p) - abs(a.d) < EPS; }

// ????????????
inline bool isCross(Line a, Line b) { return abs(a.d.cross(b.d)) > EPS; }
inline bool isCross(Line a, LineSeg b) { return sign(a.d.cross(b.p - a.p)) * sign(a.d.cross(b.p + b.d - a.d)) <= 0; }
inline bool isCross(LineSeg a, Line b) { return isCross(b, a); }
inline bool isCross(LineSeg a, LineSeg b)
{
	P2 ae = a.p + a.d, be = b.p + b.d;
	return clockwise(a.p, ae, b.p) * clockwise(a.p, ae, be) <= 0
		&& clockwise(b.p, be, a.p) * clockwise(b.p, be, ae) <= 0;
}

// ???????????????
inline bool isOverlap(Line a, Line b) { return abs(a.d.cross(b.p - a.p)) < EPS; }
inline bool isOverlap(Line a, LineSeg b) { return isOverlap(a, Line(b.p, b.d)); }
inline bool isOverlap(LineSeg a, Line b) { return isOverlap(b, a); }
inline bool isOverlap(LineSeg a, LineSeg b)
{
	return 0 + contains(a, b.p) + contains(a, b.p + b.d)
		+ contains(b, a.p) + contains(b, a.p + a.d) >= 2;
}

// ?????¢
inline double getDistance(P2 a, P2 b) { return (a - b).length(); }
inline double getDistance(P2 a, Line b) { return abs(b.d.cross(a - b.p) / b.d.length()); }
inline double getDistance(P2 a, LineSeg b) {
	P2 h = perpendicular_foot(a, (Line) b);
	return contains(b, h) ? getDistance(h, a)
		: min(getDistance(b.p, a), getDistance(b.p + b.d, a));
}
inline double getDistance(Line a, P2 b) { return getDistance(b, a); }
inline double getDistance(Line a, Line b) { return isCross(a, b) ? 0 : getDistance(a, b.p); }
inline double getDistance(Line a, LineSeg b) { return isCross(a, b) ? 0 : min(getDistance(a, b.p), getDistance(a, b.p + b.d)); }
inline double getDistance(LineSeg a, P2 b) { return getDistance(b, a); }
inline double getDistance(LineSeg a, Line b) { return getDistance(b, a); }
inline double getDistance(LineSeg a, LineSeg b)
{
	return isCross(a, b) ? 0 :
		min(min(getDistance(a, b.p), getDistance(a, b.p + b.d)),
		min(getDistance(a.p, b), getDistance(a.p + a.d, b)));
}

// a ?????? ta, b?????? tb ????????¢????????????ta=tb=r ?????? a??¨b????????\?????????
inline pair<pair<P2, P2>, pair<P2, P2>> get_distance_points(Line a, double ta, Line b, double tb)
{
	assert(isCross(a, b));

	P2 va = a.d.orthogonal().direction() * ta;
	P2 vb = b.d.orthogonal().direction() * tb;
	return make_pair(
		make_pair(
		crossPoint(Line(a.p + va, a.d), Line(b.p + vb, b.d)),
		crossPoint(Line(a.p + va, a.d), Line(b.p - vb, b.d))
		), make_pair(
		crossPoint(Line(a.p - va, a.d), Line(b.p + vb, b.d)),
		crossPoint(Line(a.p - va, a.d), Line(b.p - vb, b.d))
		));
}

/// ???
struct Circle
{
	P2 c;
	double r;
	Circle() : c(), r() { }
	Circle(double x, double y, double r) : c(x, y), r(r) { }
	Circle(P2 c, double r) : c(c), r(r) { }
	bool IntersectWith(const Circle &rhs) const { return abs(c - rhs.c) - (r + rhs.r) < EPS; } // ??\??????????????????
	bool Contains(const P2 &p) const { return abs(p - c) - r < EPS; } // ??\??????????????????
};
inline istream & operator>>(istream & in, Circle & c) { in >> c.c >> c.r; return in; }

// ??´?????¨??????????????????????????\??????????????¨????????????????????¨?????? contacting = false.
inline bool isCross(const Line &l, const Circle &c, bool contacting = true)
{
	return c.r - getDistance(l, c.c) >(contacting ? -EPS : EPS);
}

// ??´?????¨????????????
inline pair<P2, P2> crossPoint(const Line &l, const Circle &c)
{
	// ??????????¶?
	P2 h = perpendicular_foot(c.c, l);
	double d = (h - c.c).length(); // ??????????¶??????§?????????
	double k = sqrt(c.r * c.r - d * d); // ??????????¶????????????????
	P2 dir = l.d.direction();
	return pair<P2, P2>(h + dir * k, h - dir * k);
}

// 2??????????????????????????\??????????????¨????????????????????¨?????? contacting = false.
inline bool isCross(const Circle &A, const Circle &B, bool contacting = true)
{
	return (A.r + B.r) - (A.c - B.c).length() > (contacting ? -EPS : EPS);
}

// ??????????????????2????????????????±???????????§????????°??????????????????????(?????????????????£??????????¨???????)
inline pair<P2, P2> crossPoint(Circle A, Circle B)
{
	P2 v = B.c - A.c;
	P2 dir = v.direction(); // ???????????????????????????
	double d = v.length(); // ??????????????????????????¢
	double lh = (A.r*A.r + d*d - B.r*B.r) / (2 * d); // ??????????¶??????§????????¢
	P2 h = A.c + dir * lh; // ??????????¶?
	double lp = sqrt(A.r*A.r - lh*lh); // ??????????¶??????????????????§????????¢
	P2 p = dir.orthogonal() * lp; // ??????????¶???????????????????????????????
	return make_pair(h + p, h - p); // ???????????????
}

// 2????????\???????±??????????
vector<Line> getTangentialLine(Circle a, Circle b)
{
	vector<Line> ret;
	P2 v = b.c - a.c;
	double d = v.length();
	double bt = v.arg();

	if (d - abs(a.r - b.r) > EPS) // ?????\???2??¬
	{
		double dt = acos((a.r - b.r) / d);
		double t1 = bt - dt, t2 = bt + dt;
		ret.push_back(Line::From2Point(a.c + P2::polar(a.r, t1), b.c + P2::polar(b.r, t1)));
		ret.push_back(Line::From2Point(a.c + P2::polar(a.r, t2), b.c + P2::polar(b.r, t2)));
	}
	else if (d - abs(a.r - b.r) > -EPS) // ?????\???1??¬ (?????\)
	{
		ret.push_back(Line(a.c + v.direction() * a.r, v.orthogonal()));
	}

	if (d - (a.r + b.r) > EPS) // ?????\???2??¬ (??¢????????????)
	{
		double dt = acos((a.r + b.r) / d);
		double t1 = bt - dt, t2 = bt + dt;
		ret.push_back(Line::From2Point(a.c + P2::polar(a.r, t1), b.c - P2::polar(b.r, t1)));
		ret.push_back(Line::From2Point(a.c + P2::polar(a.r, t2), b.c - P2::polar(b.r, t2)));
	}
	else if (d - (a.r + b.r) > -EPS) // ?????\???1??¬ (??\????????????)
	{
		ret.push_back(Line(a.c + v.direction() * a.r, v.orthogonal()));
	}

	return ret;
}


/// ????????¢
struct Rect
{
	P2 l, s;
	Rect() : l(), s() { }
	Rect(double x, double y, double w, double h) : l(x, y), s(w, h) { }
	Rect(P2 location, P2 size) : l(location), s(size) { }
	bool Contains(const P2 &p) const { return p.x - l.x > -EPS && p.y - l.y > -EPS && p.x - (l.x + s.x) < EPS && p.y - (l.y + s.y) < EPS; } // ??\??????????????????
};


////////////////////
/// template end ///
////////////////////

void solve()
{
	cout << std::fixed << endl;
	READ(Circle, c);
	
	READ(int, q);
	REP(i, q)
	{
		READ(double, x1, y1, x2, y2); 
		P2 a, b;
		tie<P2>(a,b) = crossPoint(Line::From2Point(P2(x1, y1), P2(x2, y2)), c);
		if (a.x - b.x > EPS || a.x - b.x > -EPS && a.y - b.y > EPS) swap(a, b);
		WRITE(a, b);
	}
}

Measured memory_bytes: 1296