#include <iostream>
#include <iomanip>
#include <cmath>
#include <array>
#include <algorithm>
#include <cassert>

using Number = double;

const Number EPS = 1e-10;
const Number INF = 1e10;
const Number PI = acos(-1.0);

inline int sign(Number x) { return (x < -EPS) ? -1 : (x > EPS) ? +1 : 0; }
inline bool equal(Number a, Number b) { return sign(a - b) == 0; }

// change between degree and radian
inline Number to_radian(const Number degree) { return degree * PI / 180.0; }
inline Number to_degree(const Number radian) { return radian * 180.0 / PI; }


/**
 * Point in two dimensional
 */
class Point {
public:
    Number x, y;

    Point() {}
    Point(Number x, Number y) : x(x), y(y) {}

    // Arithmetic operator between points
    Point operator+(const Point &rhs) const {
        return Point(this->x + rhs.x, this->y + rhs.y);
    }
    Point operator-(const Point &rhs) const {
        return Point(this->x - rhs.x, this->y - rhs.y);
    }
    Point operator*(const Point &rhs) const { // cross product between points
        return Point(this->x * rhs.x - this->y * rhs.y,
                     this->x * rhs.x + this->y * rhs.x);
    }

    // Unary operator and compound assignment operator
    Point operator-() const {
        return Point(-this->x, -this->y);
    }
    Point& operator+=(const Point &rhs) {
        return *this = *this + rhs;
    }
    Point& operator-=(const Point &rhs) {
        return *this = *this - rhs;
    }

    // Arithmetic operator between point and number
    Point operator*(Number rhs) const {
        return Point(this->x * rhs, this->y * rhs);
    }
    Point operator/(Number rhs) const {
        return Point(this->x / rhs, this->y / rhs);
    }

    // Comparison operation
    bool operator==(const Point &rhs) const {
        return sign(this->x - rhs.x) == 0 && sign(this->y - rhs.y) == 0;
    }
    bool operator<(const Point &rhs) const {
        return (this->x < rhs.x) || (this->x == rhs.x && this->y < rhs.y);
    }

    // Other operator
    Number abs(void) const {
        return sqrt(this->x * this->x + this->y * this->y);
    }
    Number abs2(void) const {
        return this->x * this->x + this->y * this->y;
    }
    Number arg(void) const {
        return atan2(this->y, this->x);
    }
    Number dot(const Point &rhs) {
        return this->x * rhs.x + this->y * rhs.y;
    }
    Point rotate90(void) const {
        return Point(-this->y, this->x);
    }
    Point rotate(double angle) const {
        return Point(cos(angle) * this->x - sin(angle) * this->y,
                     sin(angle) * this->x + cos(angle) * this->y);
    }

};
inline Number dot(const Point &p1, const Point &p2) {
    return p1.x * p2.x + p1.y * p2.y;
}
inline Number abs_cross(const Point &p1, const Point &p2) {
    return p1.x * p2.y - p1.y * p2.x;
}
// Output of a point
std::ostream& operator<<(std::ostream &os, const Point &p) {
    return os <<  p.x << ' ' << p.y;
}
// Input of a point
std::istream& operator>>(std::istream &is, Point &p) {
    return is >> p.x >> p.y;
}

// Counter-Clockwise predicate (a, b, c)
enum CCW {
    COUNTER_CLOCKWISE = 1,      // counter clockwise
    CLOCKWISE         = -1,     // clockwise
    ONLINE_FRONT      = 2,      // a--c--b on line
    ONLINE_BACK       = -2,      // c--a--b on line
    ON_SEGMENT        = 0,     // a--b--c on line
};
CCW ccw(const Point &a, Point b, Point c) {
    b -= a;  c -= a;
    if (abs_cross(b, c) > EPS) return COUNTER_CLOCKWISE;
    if (abs_cross(b, c) < -EPS) return CLOCKWISE;
    if (dot(b, c) < 0)       return ONLINE_BACK;
    if (b.abs2() < c.abs2())   return ONLINE_FRONT;
    return ON_SEGMENT;
}


/**
 * Line in two dimensional
 */
class Line : public std::array<Point, 2> {
public:
    Line() {}
    Line(const Point &p1, const Point &p2) {
        (*this)[0] = p1;
        (*this)[1] = p2;
    }
};
// Input of a line
std::istream& operator>>(std::istream &is, Line &l) {
    return is >> l[0] >> l[1];
}
inline CCW ccw(const Line &l, const Point &p) {
    return ccw(l[0], l[1], p);
}


/**
 * Segment in two dimensional
 */
class Segment : public Line {
public:
    Segment() {}
    Segment(const Point &p1, const Point &p2) : Line(p1, p2) {}
};


/**
 * Circle in two dimensional
 */
class Circle : public Point {
public:
    Number r;
    Circle() {}
    Circle(const Point &p, Number r = 0.0) : Point(p), r(r) {}
};
// Input of a circle
std::istream& operator>>(std::istream &is, Circle &c) {
    return is >> c.x >> c.y >> c.r;
}



/**
 * Intersection testing
 */
Point Projection(const Line &l, const Point &p) {
    Point dir = l[1] - l[0];
    Number t = dot(p - l[0], dir) / dir.abs2();
    return l[0] + dir * t;
}
inline Point Reflection(const Line &l, const Point &p) {
    return Projection(l, p) * 2.0 - p;
}

inline bool IsOrthogonal(const Line &l1, const Line &l2) {
    return equal(dot(l1[0] - l1[1], l2[0] - l2[1]), 0.0);
}
inline bool IsParallel(const Line &l1, const Line &l2) {
    return equal(abs_cross(l1[0] - l1[1], l2[0] - l2[1]), 0.0);
}

inline bool IsIntersect(const Line &l, const Point &p) {
    return abs(ccw(l[0], l[1], p)) != 1;
}
inline bool IsIntersect(const Segment &s, const Point &p) {
    return ccw(s[0], s[1], p) == 0;
}
inline bool IsIntersect(const Line &l1, const Line l2) {
    return !IsParallel(l1, l2) || IsParallel(l1, Line(l1[0], l2[0]));
}
inline bool IsIntersect(const Line &l, const Segment &s) {
    return abs_cross(l[1] - l[0], s[0] - l[0]) *
        abs_cross(l[1] - l[0], s[1] - l[0]) < EPS;
}
inline bool IsIntersect(const Segment &s1, const Segment &s2) {
    return ccw(s1[0], s1[1], s2[0]) * ccw(s1[0], s1[1], s2[1]) <= 0 &&
        ccw(s2[0], s2[1], s1[0]) * ccw(s2[0], s2[1], s1[1]) <= 0;
}
inline bool IsIntersect(const Circle &c, const Point &p) { // p is in interior or boundary
    return (c - p).abs() <= c.r + EPS;
}
inline bool IsIntersect(const Circle &c, const Line &l) {
    return IsIntersect(c, Projection(l, c));
}
inline bool IsIntersect(const Circle &c1, const Circle &c2) {
    return (c1 - c2).abs() <= c1.r + c2.r && abs(c1.r - c2.r) <= (c1 - c2).abs();
}


/**
 * Distance and Intersection point
 */
inline Number Distance(const Point &p1, const Point &p2) {
    return (p1 - p2).abs();
}
inline Number Distance(const Line &l, const Point &p) {
    return (p - Projection(l, p)).abs();
}
inline Number Distance(const Segment &s, const Point &p) {
    if (sign(dot(s[1] - s[0], p - s[0])) == -1) return (p - s[0]).abs();
    if (sign(dot(s[0] - s[1], p - s[1])) == -1) return (p - s[1]).abs();
    return (p - Projection(s, p)).abs();
}
inline Number Distance(const Line &l1, const Line &l2) {
    return IsIntersect(l1, l2) ? 0 : Distance(l1, l2[0]);
}
inline Number Distance(const Line &l, const Segment &s) {
    if (IsIntersect(l, s)) return 0.0;
    return std::min(Distance(l, s[0]), Distance(l, s[1]));
}
inline Number Distance(const Segment &s1, const Segment &s2) {
    if (IsIntersect(s1, s2)) return 0.0;
    return std::min({Distance(s1, s2[0]), Distance(s1, s2[1]),
                Distance(s2, s1[0]), Distance(s2, s1[1])});
}

Point CrossPoint(const Line &s1, const Line &s2) {
    Point base = s2[1] - s2[0];
    Number d1 = abs(abs_cross(base, s1[0] - s2[0]));
    Number d2 = abs(abs_cross(base, s1[1] - s2[0]));
    Number t = d1 / (d1 + d2);
    return s1[0] + (s1[1] - s1[0]) * t;
}
std::pair<Point, Point> CrossPoint(const Circle &c1, const Circle &c2) {
    Number d = Distance(c1, c2);
    Number rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2.0 * d);
    Number rs = sqrt(c1.r * c1.r - rc * rc);
    Point diff = (c2 - c1) / d;
    return std::make_pair(c1 + diff * Point(rc, rs), c1 + diff * Point(rc, -rs));
}
std::pair<Point, Point> CrossPoint(const Circle &c, const Line &l) {
    assert(true);
    Point mid = Projection(l, c);
    Point e = (l[1] - l[0]) / (l[1] - l[0]).abs();
    Number len = sqrt(c.r * c.r - (mid - c).abs2());
    return std::make_pair(mid + e * len, mid - e * len);
}


int main()
{
    std::cout << std::fixed << std::setprecision(15);

    Circle c;
    Line l;
    int q;

    std::cin >> c >> q;

    while (q--) {
        std::cin >> l;
        auto ans = CrossPoint(c, l);
        if (ans.second < ans.first)
            std::swap(ans.first, ans.second);
        std::cout << ans.first << ' ' << ans.second << '\n';
    }


    return 0;
}

Measured memory_bytes: 3292