#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, b, e) for (intmax_t i = (b), i##_limit = (e); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class Container>
struct reverse_t {
    Container &c;
    reverse_t(Container &c) : c(c) {}
    auto begin() { return c.rbegin(); }
    auto end() { return c.rend(); }
};

template <class Container>
auto reversed(Container &c) {
    return reverse_t<Container>(c);
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

// Geometry {{{
const long double EPS = 1e-10;
const long double PI = acos(-1);

static const int CCW_COUNTER_CLOCKWISE = 1;
static const int CCW_CLOCKWISE = -1;
static const int CCW_ONLINE_BACK = 2;
static const int CCW_ONLINE_FRONT = -2;
static const int CCW_ON_SEGMENT = 0;

static const int ICC_SEPARATE = 4;
static const int ICC_CIRCUMSCRIBE = 3;
static const int ICC_INTERSECT = 2;
static const int ICC_INSCRIBE = 1;
static const int ICC_CONTAIN = 0;

struct Real {
    long double x;

    Real(long double x = 0) : x(x) {}
    Real(const Real& rhs) { x = rhs.x; }

    Real operator+(const Real& rhs) const { return Real(x + rhs.x); }
    Real& operator+=(const Real& rhs) { return x += rhs.x, *this; }
    Real operator-(const Real& rhs) const { return Real(x - rhs.x); }
    Real& operator-=(const Real& rhs) { return x -= rhs.x, *this; }
    Real operator*(const Real& rhs) const { return Real(x * rhs.x); }
    Real& operator*=(const Real& rhs) { return x *= rhs.x, *this; }
    Real operator/(const Real& rhs) const { return Real(x / rhs.x); }
    Real& operator/=(const Real& rhs) { return x /= rhs.x, *this; }
    Real operator-() const { return Real(-x); }
    Real& operator++() { return ++x, *this; }
    Real& operator--() { return --x, *this; }
    Real operator++(int) { Real tmp(x); return ++x, tmp; }
    Real operator--(int) { Real tmp(x); return --x, tmp; }
    bool operator==(const Real& rhs) const { return fabs(x - rhs.x) < EPS; }
    bool operator!=(const Real& rhs) const { return !(*this == rhs); }
    bool operator<(const Real& rhs) const { return (*this == rhs) ? false : x < rhs.x; }
    bool operator>(const Real& rhs) const { return (*this == rhs) ? false : x > rhs.x; }
    bool operator<=(const Real& rhs) const { return (*this == rhs) ? true : x < rhs.x; }
    bool operator>=(const Real& rhs) const { return (*this == rhs) ? true : x > rhs.x; }

    friend istream& operator>>(istream& is, Real& rhs) {
        is >> rhs.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const Real& rhs) {
        os << rhs.x;
        return os;
    }

    friend Real pow(const Real& n, const Real& p) { return pow(n.x, p.x); }
    friend Real pow(Real n, intmax_t p) {
        Real ret = 1;
        for (; p > 0; p >>= 1) {
            if (p & 1) ret *= n;
            n *= n;
        }
        return ret;
    }
    friend Real abs(const Real& rhs) { return abs(rhs.x); }
    friend Real sin(const Real& rhs) { return sin(rhs.x); }
    friend Real cos(const Real& rhs) { return cos(rhs.x); }
    friend Real tan(const Real& rhs) { return tan(rhs.x); }
    friend Real asin(const Real& rhs) { return asin(rhs.x); }
    friend Real acos(const Real& rhs) { return acos(rhs.x); }
    friend Real atan(const Real& rhs) { return atan(rhs.x); }
    friend Real atan2(const Real& lhs, const Real& rhs) { return atan2(lhs.x, rhs.x); }
    friend Real sqrt(const Real& rhs) { return sqrt(rhs.x); }
    friend Real ceil(const Real& rhs) { return ceil(rhs.x); }
    friend Real floor(const Real& rhs) { return floor(rhs.x); }
    friend Real round(const Real& rhs) { return round(rhs.x); }
};

using real_t = Real;

struct Point {
    real_t x, y;

    Point(real_t x = 0, real_t y = 0) : x(x), y(y) {}

    Point operator+(const Point& rhs) const { return Point(x + rhs.x, y + rhs.y); }
    Point operator-(const Point& rhs) const { return Point(x - rhs.x, y - rhs.y); }
    Point operator*(const real_t& rhs) const { return Point(x * rhs, y * rhs); }
    Point operator/(const real_t& rhs) const { return Point(x / rhs, y / rhs); }
    Point operator-() const { return Point(-x, -y); }
    bool operator==(const Point& rhs) const { return x == rhs.x && y == rhs.y; }
    bool operator!=(const Point& rhs) const { return !(*this == rhs); }
    bool operator<(const Point& rhs) const { return (x == rhs.x) ? y < rhs.y : x < rhs.x; }
    bool operator>(const Point& rhs) const { return (x == rhs.x) ? y > rhs.y : x > rhs.x; }
    bool operator<=(const Point& rhs) const { return (*this == rhs) ? true : *this < rhs; }
    bool operator>=(const Point& rhs) const { return (*this == rhs) ? true : *this > rhs; }

    friend istream& operator>>(istream& is, Point& rhs) {
        is >> rhs.x >> rhs.y;
        return is;
    }
    friend ostream& operator<<(ostream& os, const Point& rhs) {
        os << rhs.x << ' ' << rhs.y;
        return os;
    }
};

using Vector = Point;
using Polygon = vector<Point>;

real_t norm(const Vector& a) { return a.x * a.x + a.y * a.y; }
real_t len(const Vector& a) { return sqrt(norm(a)); }
real_t dot(const Vector& a, const Vector& b) { return a.x * b.x + a.y * b.y; }
real_t cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y * b.x; }

struct Segment {
    Point p1, p2;

    Segment(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator==(const Segment& rhs) const { return p1 == rhs.p1 && p2 == rhs.p2; }
    bool operator!=(const Segment& rhs) const { return !(*this == rhs); }

    friend istream& operator>>(istream& is, Segment& rhs) {
        is >> rhs.p1 >> rhs.p2;
        return is;
    }
    friend ostream& operator<<(ostream& os, const Segment& rhs) {
        os << rhs.p1 << ' ' << rhs.p2;
        return os;
    }
};

using Line = Segment;

struct Circle {
    Point c;
    real_t r;

    Circle(Point c = Point(), real_t r = 0) : c(c), r(r) {}

    bool operator==(const Circle& rhs) const { return c == rhs.c && r == rhs.r; }
    bool operator!=(const Circle& rhs) const { return !(*this == rhs); }

    friend istream& operator>>(istream& is, Circle& rhs) {
        is >> rhs.c >> rhs.r;
        return is;
    }
    friend ostream& operator<<(ostream& os, const Circle& rhs) {
        os << rhs.c << rhs.r;
        return os;
    }
};

real_t len(const Segment& s) { return len(s.p1 - s.p2); }

bool isParallel(const Vector& a, const Vector& b) {
    return cross(a, b) == 0.0;
}
bool isParallel(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(const Segment& s1, const Segment& s2) {
    return isParallel(s1.p1, s1.p2, s2.p1, s2.p2);
}

bool isOrthogonal(const Vector& a, const Vector& b) {
    return dot(a, b) == 0.0;
}
bool isOrthogonal(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(const Segment& s1, const Segment& s2) {
    return isOrthogonal(s1.p1, s1.p2, s2.p1, s2.p2);
}

Point project(const Segment& s, const Point& p) {
    const Vector base = s.p2 - s.p1;
    const Vector hypo = p - s.p1;
    const real_t r = dot(hypo, base) / norm(base);
    return s.p1 + base * r;
}

Point reflect(const Segment& s, const Point& p) {
    return p + (project(s, p) - p) * 2.0;
}

int ccw(const Point& p0, const Point& p1, const Point& p2);
bool intersectSS(const Point& p1, const Point& p2, const Point& p3, const Point& p4);
bool intersectSS(const Segment& s1, const Segment& s2);
bool intersectGS(const Polygon& g, const Segment& s);
int intersectCC(Circle c1, Circle c2);
bool intersectSC(const Segment& s, const Circle& c);
real_t getDistancePP(const Point& p1, const Point& p2);
real_t getDistanceLP(const Line& l, const Point& p);
real_t getDistanceSP(const Segment& s, const Point& p);
real_t getDistanceSS(const Segment& s1, const Segment& s2);
Point getCrossPointSS(const Segment& s1, const Segment& s2);
Polygon getCrossPointCL(const Circle& c, const Line& l);
real_t area(const Polygon& g);

int ccw(const Point& p0, const Point& p1, const Point& p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > 0.0) return CCW_COUNTER_CLOCKWISE;
    if (cross(a, b) < 0.0) return CCW_CLOCKWISE;
    if (dot(a, b) < 0) return CCW_ONLINE_BACK;
    if (norm(a) < norm(b)) return CCW_ONLINE_FRONT;
    return CCW_ON_SEGMENT;
}

bool intersectSS(const Point& p1, const Point& p2, const Point& p3, const Point& p4) {
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}

bool intersectSS(const Segment& s1, const Segment& s2) {
    return intersectSS(s1.p1, s1.p2, s2.p1, s2.p2);
}

bool intersectGS(const Polygon& g, const Segment& s) {
    const size_t N = g.size();
    for (size_t i = 0; i < N; ++i) {
        if (intersectSS(Segment(g[i], g[(i + 1) % N]), s)) return true;
    }
    return false;
}

int intersectCC(Circle c1, Circle c2) {
    if (c1.r < c2.r) swap(c1, c2);
    const real_t d = len(c1.c - c2.c);
    const real_t r = c1.r + c2.r;
    if (d == r) return ICC_CIRCUMSCRIBE;
    if (d > r) return ICC_SEPARATE;
    if (d + c2.r == c1.r) return ICC_INSCRIBE;
    if (d + c2.r < c1.r) return ICC_CONTAIN;
    return ICC_INTERSECT;
}

bool intersectSC(const Segment& s, const Circle& c) {
    return getDistanceSP(s, c.c) <= c.r;
}

real_t getDistancePP(const Point& p1, const Point& p2) {
    return len(p2 - p1);
}

real_t getDistanceLP(const Line& l, const Point& p) {
    return abs(cross(l.p2 - l.p1, p - l.p1) / len(l.p2 - l.p1));
}

real_t getDistanceSP(const Segment& s, const Point& p) {
    if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return getDistancePP(p, s.p1);
    if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return getDistancePP(p, s.p2);
    return getDistanceLP(s, p);
}

real_t getDistanceSS(const Segment& s1, const Segment& s2) {
    if (intersectSS(s1, s2)) return 0.0;
    const real_t opt1 = getDistanceSP(s1, s2.p1);
    const real_t opt2 = getDistanceSP(s1, s2.p2);
    const real_t opt3 = getDistanceSP(s2, s1.p1);
    const real_t opt4 = getDistanceSP(s2, s1.p2);
    return min({opt1, opt2, opt3, opt4});
}

Point getCrossPointSS(const Segment& s1, const Segment& s2) {
    Vector base = s2.p2 - s2.p1;
    const real_t d1 = abs(cross(base, s1.p1 - s2.p1));
    const real_t d2 = abs(cross(base, s1.p2 - s2.p1));
    const real_t t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}

Polygon getCrossPointCL(const Circle& c, const Line& l) {
    Polygon ps;
    const Point pr = project(l, c.c);
    const Vector e = (l.p2 - l.p1) / len(l.p2 - l.p1);
    if (getDistanceLP(l, c.c) == c.r) {
        ps.emplace_back(pr);
        return ps;
    }
    const real_t base = sqrt(c.r * c.r - norm(pr - c.c));
    ps.emplace_back(pr + e * base);
    ps.emplace_back(pr - e * base);
    return ps;
}

real_t area(const Polygon& g) {
    const size_t N = g.size();
    real_t res = 0;
    for (size_t i = 0; i < g.size(); ++i) {
        res += cross(g[i], g[(i + 1) % N]) / 2.0;
    }
    return res;
}
// }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    var(Circle, c);
    var(size_t, Q);

    while (Q--) {
        var(Line, l);
        auto res = getCrossPointCL(c, l);
        if (res.size() == 1) {
            output(res[0], res[0]);
        } else {
            if (res[0] > res[1]) swap(res[0], res[1]);
            output(res[0], res[1]);
        }
    }

    return 0;
}



Measured memory_bytes: 3300