#include <bits/stdc++.h>
using namespace std;

const int MAXN = 50000 + 10;
const double pi = acos(-1.0);
const double inf = 1e100;
const double eps = 1e-12;

struct vec { //点的基本数据结构
    double x, y;
    vec(double _x = 0, double _y = 0)
        : x(_x)
        , y(_y)
    {
    }
    vec operator*(const vec& i_T) const
    {
        return vec(x * i_T.x, y * i_T.y);
    }
    vec operator*(double u) const
    {
        return vec(x * u, y * u);
    }
    bool operator==(const vec& i_T) const
    {
        return x == i_T.x && y == i_T.y;
    }
    vec operator/(double u) const
    {
        return vec(x / u, y / u);
    }
    vec operator+(const vec& i_T)
    {
        return vec(x + i_T.x, y + i_T.y);
    }
    vec operator-(const vec& i_T)
    {
        return vec(x - i_T.x, y - i_T.y);
    }
    friend bool operator<(vec a, vec b)
    {
        return a.y == b.y ? a.x < b.x : a.y < b.y;
    }
    friend ostream& operator<<(ostream& out, vec& a)
    {
        //cout << a.x << ' ' << a.y;
        printf("%.8f %.8f", a.x, a.y);
        return out;
    }
    friend istream& operator>>(istream& in, vec& a)
    {
        in >> a.x >> a.y;
        return in;
    }
};
struct cirles {
    vec o;
    double r;
    friend istream& operator>>(istream& in, cirles& a)
    {
        in >> a.o >> a.r;
        return in;
    }
    friend ostream& operator<<(ostream& out, cirles& a)
    {
        out << a.o << ' ' << a.r;
        return out;
    }
};
struct Line {
    vec a, b;
    friend istream& operator>>(istream& in, Line& a)
    {
        cin >> a.a >> a.b;
        return in;
    }
    friend ostream& operator<<(ostream& out, Line& a)
    {
        out << a.a << ' ' << a.b;
        return out;
    }
};
double changdu(vec a) //长度
{
    return sqrt(a.x * a.x + a.y * a.y);
}
double chaji(vec A, vec B) //求向量叉积
{
    return A.x * B.y - A.y * B.x; // 正为A->B左旋
}
double dianji(vec A, vec B) //点积
{
    return A.x * B.x + A.y * B.y;
}
vec touying(Line l, vec c) //c投影在ab上的位置
{
    vec A = l.b - l.a;
    vec B = c - l.a;
    double La = changdu(A);
    double Lc = dianji(A, B) / (La * La);
    return vec(Lc * A.x, Lc * A.y) + l.a;
}
int zhengfu(double d) //判断正负
{
    if (fabs(d) < eps)
        return 0;
    if (d > 0)
        return 1;
    return -1;
}
int dayu_dengyu(double x, double y)
{
    if (x > y || fabs(x - y) < eps)
        return 1;
    return 0;
}
double zhixian_yuanxin_juli(Line l, cirles a) //直线到圆心的距离
{
    return fabs(chaji(a.o - l.a, l.b - l.a)) / changdu(l.b - l.a);
}
pair<vec, vec> zhixian_yuan_jiaodian(Line l, cirles a)
{
    if (dayu_dengyu(a.r, zhixian_yuanxin_juli(l, a))) {
        vec a_i = touying(l, a.o);
        double L = changdu(l.b - l.a);
        double lt = changdu(a.o - a_i);
        double lr = sqrt(a.r * a.r - lt * lt);
        vec p = (l.b - l.a) / L * lr + a_i;
        return make_pair(a_i - (l.b - l.a) / L * lr, a_i + (l.b - l.a) / L * lr);
    } else
        return make_pair(0, 0);
}
/*
2 1 1
1
0 1 4 1
*/
int main()
{
  //  freopen("txt.txt", "w", stdout);
    cirles a;
    cin >> a;
    int q;
    cin >> q;
    while (q--) {
        Line l;
        cin >> l;

        pair<vec, vec> q = zhixian_yuan_jiaodian(l, a);
        if (fabs(q.first.x - q.second.x) < eps) {
            if (dayu_dengyu(q.first.y, q.second.y))
                cout << q.second << ' ' << q.first << endl;
            else
                cout << q.first << ' ' << q.second << endl;
        } else if (dayu_dengyu(q.first.x, q.second.x))
            cout << q.second << ' ' << q.first << endl;
        else
            cout << q.first << ' ' << q.second << endl;
    }
}


Measured memory_bytes: 3296