#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-10, pi = acos((double)-1);
#define equals(a, b) (fabs((a) - (b)) < eps)
struct Point
{
    double x, y;
    Point(const double &a = 0, const double &b = 0) : x(a), y(b) {}
    void input()
    {
        scanf("%lf%lf", &x, &y);
    }
    Point operator+(const Point &t)
    {
        return Point(x + t.x, y + t.y);
    }
    Point operator-(const Point &t)
    {
        return Point(x - t.x, y - t.y);
    }
    Point operator*(const double &k)
    {
        return Point(k * x, k * y);
    }
    Point operator/(const double &k)
    {
        return Point(x / k, y / k);
    }
    Point turn(double T) // 逆时针旋转T弧度
    {
        return Point(x * cos(T) - y * sin(T),
        x * sin(T) + y * cos(T));
    }
    Point Normal() // 求单位法向量
    {
        return Point(-(y / length()), x / length());
    }
    double operator*(const Point &t) // 内积
    {
        return (x * t.x + y * t.y);
    }
    double operator^(const Point &t) // 叉积
    {
        return (x * t.y - y * t.x);
    }
    bool operator==(const Point &t) // 判断是否相等
    {
        return equals((x - t.x), 0.0) && equals((y - t.y), 0.0);
    }
    double norm()
    {
        return x * x + y * y;
    }
    double length() // 向量长度
    {
        return sqrt(norm());
    }
};
typedef Point Vector;
struct Segment
{
    Point p1, p2;
    Vector base()
    {
        return Vector(p2 - p1);
    }
};
typedef Segment Line;
struct Circle
{
    Point c; double r;
    Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
    void input()
    {
        c.input(); scanf("%lf", &r);
    }
};
typedef vector<Point> Polygon;
double Dist(Point a, Point b) // 两点距离
{
    return (a - b).length();
}
double Angle(Vector a, Vector b) // 求两向量夹角
{
    return acos(a * b / (a.length() * b.length()));
}
bool isOrthogonal(Vector a, Vector b) // 两向量是否正交
{
    return equals((a * b), 0.0);
}
bool isParallel(Vector a, Vector b) // 两向量是否平行
{
    return equals((a ^ b), 0.0);
}
bool istouch(Point a, Vector v, Point c, double r) // 直线a->v是否与圆c相交（不相切）
{
    Point b = a + v;
    return (fabs((a - c) ^ (b - c)) / Dist(a, b) < r);
}
bool isOnShot(Point a, Vector v, Point b) // b是否在射线a->v上
{
    return isParallel((b - a), v) && ((b - a) * v >= eps);
}
bool isOnSeg(Point a, Point b, Point c) // c是否在线段ab上
{
    return isParallel((c - a), (c - b)) && ((c - a) * (c - b) < eps);
}
Point getCrossPoint(Segment s1, Segment s2) // 求两线段的交点
{
    double d1 = fabs((s2.base() ^ (s1.p1 - s2.p1)));
    double d2 = fabs((s2.base() ^ (s1.p2 - s2.p1)));
    double t = d1 / (d1 + d2);
    return s1.p1 + s1.base() * t;
}
Point Projection(Line s, Point p) // 点p在直线s上的投影
{
    double r = ((p - s.p1) * s.base()) / s.base().norm();
    return s.p1 + s.base() * r;
}
Point Reflection(Line s, Point p) // 点p关于直线s的对称点
{
    return p + (Projection(s, p) - p) * 2.0;
}
double DistLP(Line s, Point p) // 点p到直线s的距离
{
    return fabs(s.base() ^ (p - s.p1)) / s.base().length();
}
double DistSP(Segment s, Point p) // 点p到线段s的距离
{
    if((s.base() * (p - s.p1)) < 0.0) return (p - s.p1).length();
    if(((s.p1 - s.p2) * (p - s.p2)) < 0.0)  return (p - s.p2).length();
    return DistLP(s, p);
}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2) // 点p2在线段p0p1的逆时针/顺时针方向或者在线段p0p1前/后/上
{
    Vector v1 = p1 - p0, v2 = p2 - p0;
    if((v1 ^ v2) > eps) return COUNTER_CLOCKWISE;
    if((v1 ^ v2) < -eps) return CLOCKWISE;
    if((v1 * v2) < -eps) return ONLINE_BACK;
    if(v1.norm() < v2.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool Intersect(Point p1, Point p2, Point p3, Point p4) // 线段p1p2和线段p3p4是否相交
{
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
    ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool Intersect(Segment s1, Segment s2) // 线段s1和线段s2是否相交
{
    return Intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
bool Intersect(Circle c, Line l) // 圆c与直线l是否相交
{
    return (DistLP(l, c.c) < c.r) || equals(DistLP(l, c.c), c.r);
}
double DistSS(Segment s1, Segment s2) // 线段s1与线段s2的距离
{
    if(Intersect(s1, s2)) return 0.0;
    return min(min(DistSP(s1, s2.p1), DistSP(s1, s2.p2)),
    min(DistSP(s2, s1.p1), DistSP(s2, s1.p2)));
}
pair<Point, Point> getCrossPoints(Circle c, Line l)
{
    Point pr = Projection(l, c.c);
    Vector e = l.base() / l.base().length();
    double base = sqrt(c.r * c.r - (pr - c.c).norm());
    return make_pair(pr + e * base, pr - e * base);
}
inline int read()
{
    int w = 1, s = 0; char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') w = -1; ch = getchar(); }
    while(isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
    return w * s;
}
int main()
{
    Circle c; c.input();
    int q = read();
    while(q--)
    {
        Line l;
        l.p1.input(), l.p2.input();
        pair<Point, Point> tp;
        if(Intersect(c, l)) tp = getCrossPoints(c, l);
        if(tp.first.x < tp.second.x || (equals(tp.first.x, tp.second.x) && tp.first.y < tp.second.y))
            printf("%.10lf %.10lf %.10lf %.10lf\n", tp.first.x, tp.first.y, tp.second.x, tp.second.y);
        else
            printf("%.10lf %.10lf %.10lf %.10lf\n", tp.second.x, tp.second.y, tp.first.x, tp.first.y);
    }
//    system("pause");
}


Measured memory_bytes: 3240