#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

using D = double;
const D PI = acos(D(-1)), EPS = 1e-10;

struct Pt2 {
    D x, y;
    Pt2() {}
    Pt2(D _x, D _y) : x(_x), y(_y) {}
    Pt2 operator+(const Pt2 &r) const { return Pt2(x+r.x, y+r.y); }
    Pt2 operator-(const Pt2 &r) const { return Pt2(x-r.x, y-r.y); }
    Pt2 operator*(const Pt2 &r) const { return Pt2(x*r.x-y*r.y, x*r.y+y*r.x); }

    Pt2 operator*(const D &r) const { return Pt2(x*r, y*r); }
    Pt2 operator/(const D &r) const { return Pt2(x/r, y/r); }

    Pt2& operator+=(const Pt2 &r) { return *this=*this+r; }
    Pt2& operator-=(const Pt2 &r) { return *this=*this-r; }
    Pt2& operator*=(const Pt2 &r) { return *this=*this*r; }
    Pt2& operator*=(const D &r) { return *this=*this*r; }
    Pt2& operator/=(const D &r) { return *this=*this/r; }
    
    Pt2 operator-() const { return Pt2(-x, -y); }

    D abs() const { return sqrt(x*x + y*y); }
    D rabs() const { return max(::abs(x), ::abs(y)); } // robust abs
    D arg() const { return atan2(y, x); }

    pair<D, D> to_pair() const { return make_pair(x, y); }
    static Pt2 polar(D le, D th) { return Pt2(le*cos(th), le*sin(th)); }
};
ostream& operator<<(ostream& os, const Pt2 &p) {
    os << "(" << p.x << ", " << p.y << ")";
    return os;
}
using P = Pt2;

struct L {
    P s, t;
    L() {}
    L(P _s, P _t) : s(_s), t(_t) {}
    P vec() const { return t-s; }
    D abs() const { return vec().abs(); }
    D arg() const { return vec().arg(); }
};

int sgn(D a) {
    if (abs(a) <= EPS) return 0;
    return (a < 0) ? -1 : 1;
}
int sgn(D a, D b) { return sgn(a-b); }
//relative sign
int rsgn(D a, D f) {
    if (abs(a) <= f*EPS) return 0;
    return (a < 0) ? -1 : 1;
}

//robust less
bool rless(P l, P r) {
    if (sgn(r.x-l.x)) return l.x < r.x;
    if (sgn(r.y-l.y)) return l.y < r.y;
    return false;
}

D cross(P a, P b) { return a.x*b.y - a.y*b.x; }
D dot(P a, P b) { return a.x*b.x + a.y*b.y; }

// -2, -1, 0, 1, 2 : front, clock, on, cclock, back
int ccw(P b, P c) {
    int s = rsgn(cross(b, c), b.rabs());
    if (s) return s;
    if (!sgn(c.rabs()) || !sgn((c-b).rabs())) return 0;
    if (dot(b, c) < 0) return 2;
    if (dot(-b, c-b) < 0) return -2;
    return 0;
}
int ccw(P a, P b, P c) { return ccw(b-a, c-a); }
int ccw(L l, P p) { return ccw(l.s, l.t, p); }

int crossLL(const L &l, const L &m, P &r) {
    if (sgn(cross(l.vec(), m.vec())) == 0) {
        r = l.s;
        if (ccw(l.s, l.t, m.s) % 2 == 0) return -1;
        return 0;
    }
    D t = cross(l.vec(), l.t - m.s) / cross(l.vec(), m.vec());
    r = m.s + m.vec() * t;
    return 1;
}

struct C {
    P p; D r;
    C() {}
    C(P p, D r) : p(p), r(r) {}
};

P project(const L &l, const P &p) {
    P v = l.vec();
    return l.s + v * (dot(v, p-l.s) / (v.x*v.x + v.y*v.y));
}

D distLP(const L &l, const P &p) {
    return abs(cross(l.vec(), p-l.s)) / l.abs();
}

//need Intersect/distLP
int crossLC(const L &l, const C &c, L &r) {
    D u = distLP(l, c.p);
    int si = sgn(u - c.r);
    if (si == 1) return 0;
/*    P v = (l.t-l.s) / l.abs() * P(0, -1); //lに直行する単位ベクトル
    v *= u;
    if (ccw(l.s, l.t, c.p) < 0) v *= -1;*/
    P v = project(l, c.p);
    //vは円の中心からlへと向かう方向のベクトル
    if (si == 0) {
        r.s = r.t = v;
        return 1;
    }
    r.s = v+P::polar(sqrt(c.r*c.r - u*u), l.arg());
    r.t = v-P::polar(sqrt(c.r*c.r - u*u), l.arg());
    return 2;
}

//共通内接線
int internal_tangent(const C &c, const C &d, L &l, L &r) {
    D di = (c.p - d.p).abs();
    if (sgn(c.r + d.r, di) == 1) return 0;
    D th = acos((c.r+d.r) / di);
    D ar = (d.p - c.p).arg();
    l.s = c.p + P::polar(c.r, ar-th);
    l.t = d.p - P::polar(d.r, ar-th);
    r.s = c.p + P::polar(c.r, ar+th);
    r.t = d.p - P::polar(d.r, ar+th);
    if (sgn(di, c.r + d.r) == 0) return 1;
    return 2;
}

//共通外接線
int external_tangent(const C &c, const C &d, L &l, L &r) {
    D di = (c.p - d.p).abs();
    if (sgn(abs(c.r - d.r), di) == 1) return 0;
    assert(sgn(di)); // prohibit same circles
    D th = acos((c.r-d.r) / di);
    D ar = (d.p - c.p).arg();
    l.s = c.p + P::polar(c.r, ar-th);
    l.t = d.p + P::polar(d.r, ar-th);
    r.s = c.p + P::polar(c.r, ar+th);
    r.t = d.p + P::polar(d.r, ar+th);
    if (sgn(di, abs(c.r - d.r)) == 0) return 1;
    return 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    D x, y, r;
    cin >> x >> y >> r;
    C c = C(P(x, y), r);
    
    int q;
    cin >> q;
    for (int ph = 0; ph < q; ph++) {
        P p1, p2;
        cin >> x >> y; p1 = P(x, y);
        cin >> x >> y; p2 = P(x, y);
        L l;
        crossLC(L(p1, p2), c, l);
        if (!rless(l.s, l.t)) swap(l.s, l.t);
        cout << l.s.x << " " << l.s.y << " " << l.t.x << " " << l.t.y << endl;
    }
    
/*    C c1, c2;
    D x, y, r;
    cin >> x >> y >> r; c1 = C(P(x, y), r);
    cin >> x >> y >> r; c2 = C(P(x, y), r);

    L l1, l2;
    int z;
    V<P> res;
    z = internal_tangent(c2, c1, l1, l2);
    if (z >= 1) res.push_back(l1.t);
    if (z >= 2) res.push_back(l2.t);
    z = external_tangent(c2, c1, l1, l2);
    if (z >= 1) res.push_back(l1.t);
    if (z >= 2) res.push_back(l2.t);

    sort(begin(res), end(res), rless);
    for (auto p: res) {
        cout << p.x << " " << p.y << endl;
    }*/
    return 0;
}



Measured memory_bytes: 3744