#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct Circle {
    double x, y, r;
};
struct Line {
    double a, b, c;
};
vector<pair<double, double>> CrossPoints_of_Circles(Circle c1, Circle c2) {
    double x1, y1, r1, x2, y2, r2;
    x1 = c1.x, y1 = c1.y, r1 = c1.r;
    x2 = c2.x, y2 = c2.y, r2 = c2.r;
    vector<pair<double, double>> ret;
    if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) > (r1 + r2) * (r1 + r2))
        return ret;
    if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) < (r1 - r2) * (r1 - r2))
        return ret;
    double a = 2 * (x1 - x2), b = 2 * (y1 - y2),
           c = -x1 * x1 - y1 * y1 + x2 * x2 + y2 * y2 + r1 * r1 - r2 * r2;

    double d = a * x1 + b * y1 + c;
    double X, Y;
    X = (-a * d + b * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        x1;
    Y = (-b * d - a * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        y1;
    ret.emplace_back(X, Y);
    X = (-a * d - b * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        x1;
    Y = (-b * d + a * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        y1;
    ret.emplace_back(X, Y);
    sort(all(ret));
    return ret;
}

vector<pair<double, double>> CrossPoints_of_a_Circle_and_a_Line(Circle c1,
                                                                Line l1) {
    double x, y, r, a, b, c;
    x = c1.x, y = c1.y, r = c1.r;
    a = l1.a, b = l1.b, c = l1.c;
    vector<pair<double, double>> ret;

    if (abs(a * x + b * y + c) / sqrt(a * a + b * b) > r) return ret;

    double d = a * x + b * y + c;
    double X, Y;
    X = (-a * d + b * sqrt((a * a + b * b) * r * r - d * d)) / (a * a + b * b) +
        x;
    Y = (-b * d - a * sqrt((a * a + b * b) * r * r - d * d)) / (a * a + b * b) +
        y;
    ret.emplace_back(X, Y);
    X = (-a * d - b * sqrt((a * a + b * b) * r * r - d * d)) / (a * a + b * b) +
        x;
    Y = (-b * d + a * sqrt((a * a + b * b) * r * r - d * d)) / (a * a + b * b) +
        y;
    ret.emplace_back(X, Y);
    sort(all(ret));
    return ret;
}

int main() {
    cout << fixed << setprecision(20);
    Circle c;
    cin >> c.x >> c.y >> c.r;
    int q;
    cin >> q;
    while (q--) {
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        Line l = {y2 - y1, x1 - x2, -x1 * (y2 - y1) + y1 * (x2 - x1)};
        auto ans = CrossPoints_of_a_Circle_and_a_Line(c, l);
        for (auto p : ans) cout << p.first << " " << p.second << endl;
    }
}


Measured memory_bytes: 3300