#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace asl
{
    
    template <typename numeric_type>
    class point
    {
    public:
        numeric_type x, y;

        point(numeric_type x = 0, numeric_type y = 0) : x(x), y(y) {}

        bool operator<(const point<numeric_type> &ri) const
        {
            if (x != ri.x)
                return x < ri.x;
            return y < ri.y;
        }

        point<numeric_type> &operator+=(const point<numeric_type> &ri)
        {
            x += ri.x;
            y += ri.y;
            return *this;
        }

        point<numeric_type> &operator-=(const point<numeric_type> &ri)
        {
            x -= ri.x;
            y -= ri.y;
            return *this;
        }

        point<numeric_type> &operator*=(const point<numeric_type> &ri)
        {
            auto _x = x * ri.x - y * ri.y;
            auto _y = x * ri.y + y * ri.x;
            x = _x;
            y = _y;
            return *this;
        }

        friend point<numeric_type> operator+(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) += b;
        }

        friend point<numeric_type> operator-(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) -= b;
        }

        friend point<numeric_type> operator*(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) *= b;
        }

    };

    template <typename numeric_type>
    std::ostream &operator<<(std::ostream &out, const point<numeric_type> &p)
    {
        return out << p.x << " " << p.y;
    }

    template <typename numeric_type>
    std::istream &operator>>(std::istream &is, point<numeric_type> &p)
    {
        return is >> p.x >> p.y;
    }

    template <typename numeric_type>
    numeric_type dot(point<numeric_type> a, point<numeric_type> b)
    {
        return a.x * b.x + a.y * b.y;
    }

    template <const int eps_exp = 9>
    int sign(double v)
    {
        const double eps = std::pow(10, -eps_exp);

        if (v < -eps)
            return -1;
        else if (v > eps)
            return +1;
        else
            return 0;
    }

#include <stdint.h>

    template <typename T>
    std::ostream &operator<<(std::ostream &out, const std::vector<T> &vec)
    {
        bool start = true;

        for (auto x : vec)
        {
            if (start)
            {
                start = false;
            }
            else
            {
                out << " ";
            }

            out << x;
        }
        return out;
    }

} 

#include <experimental/optional>

namespace asl
{
    template <typename numeric_type>
    class line
    {
    public:
        point<numeric_type> p, q;

    };

    template <typename numeric_type>
    std::istream &operator>>(std::istream &is, line<numeric_type> &l)
    {
        return is >> l.p >> l.q;
    }

    template <typename numeric_type>
    class circle
    {
    public:
        point<numeric_type> p;
        numeric_type r;
    };

    template <typename numeric_type>
    std::istream &operator>>(std::istream &is, circle<numeric_type> &c)
    {
        return is >> c.p >> c.r;
    }

    template <typename numeric_type>
    std::vector<point<numeric_type>> intersect_circle_line(const circle<numeric_type> &circ, const line<numeric_type> &l)
    {
        auto u = l.p - l.q, v = l.p - circ.p;
        auto a = dot(u, u), b = dot(u, v), c = dot(v, v) - circ.r * circ.r;
        auto det = b * b - a * c;
        if (sign(det) < 0)
            return {};
        if (sign(det) == 0)
            return {l.p - b / a * u};
        return {l.p + (-b + sqrt(det)) / a * u,
                l.p + (-b - sqrt(det)) / a * u};
    }

} 

#include <random>

#define endl '\n'

using namespace asl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(12);
    cout << fixed;

    circle<double> c;
    cin >> c;
    int q;
    cin >> q;

    while (q--)
    {
        line<double> l;
        cin >> l;

        auto res = intersect_circle_line(c, l);
        sort(res.begin(), res.end());

        if (res.size() == 1)
            res.push_back(res[0]);

        cout << res << endl;
    }

    return 0;
}





Measured memory_bytes: 3312