using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;


namespace AOJ
{
    using Vector = Point;
    using Line = Segment;
    using Polygon = List<Point>;

    class Consts
    {
        public static readonly double EPS = 1e-10;
    }
    class Point
    {
        double x, y;
        public double X { get { return this.x; } set { this.x = value; } }
        public double Y { get { return this.y; } set { this.y = value; } }
        public Point(double x = 0, double y = 0)
        {
            this.x = x;
            this.y = y;
        }

        static public Point operator +(Point p1, Point p2) => new Point(p1.x + p2.x, p1.y + p2.y);
        static public Point operator -(Point p1, Point p2) => new Point(p1.x - p2.x, p1.y - p2.y);
        static public Point operator *(Point p, double a) => new Point(a * p.x, a * p.y);
        static public Point operator *(double a, Point p) => p * a;
        static public Point operator /(Point p, double a) => new Point(p.x / a, p.y / a);
        static public bool operator <(Point p1, Point p2) => p1.x != p2.x ? p1.x < p2.x : p1.y < p2.y;
        static public bool operator >(Point p1, Point p2) => p2 < p1;

        static public bool operator ==(Point p1, Point p2) => (p1.x - p2.x) < Consts.EPS && (p1.y - p2.y) < Consts.EPS;
        static public bool operator !=(Point p1, Point p2) => !(p1 == p2);

        public double abs() => Math.Sqrt(norm());
        public double norm() => this.x * this.x + this.y * this.y;

        public override bool Equals(object obj)
        {
            if ((object)obj == null || this.GetType() != obj.GetType())
            {
                return false;
            }
            var c = (Point)obj;
            return this == c;
        }
        public override int GetHashCode()
        {
            return this.x.GetHashCode() ^ this.y.GetHashCode();
        }
    }
    struct Segment
    {
        public Segment(Point p1,Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
        public Point p1, p2;
    }
    class Circle
    {
        public Point c;
        public double r;
        public Circle(Point c, double r)
        {
            this.c = c;
            this.r = r;
        }
    }

    class VecCalc
    {
        static bool equals(double a, double b) => Math.Abs(a - b) < Consts.EPS;
        //内積
        static public double dot(Vector a, Vector b)
        {
            return a.X * b.X + a.Y * b.Y;
        }
        //外積
        static public double cross(Vector a, Vector b)
        {
            return a.X * b.Y - a.Y * b.X;
        }
        //16.2 直行判定
        static public bool isOrthogonal(Vector a, Vector b)
        {
            return equals(dot(a, b), 0.0);
        }
        static public bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
        {
            return isOrthogonal(a1 - a2, b1 - b2);
        }
        static public bool isOrthogonal(Segment s1, Segment s2)
        {
            return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
        }
        //16.2 平行判定
        static public bool isParallel(Vector a, Vector b)
        {
            return equals(cross(a, b), 0.0);
        }
        static public bool isParallel(Point a1, Point a2, Point b1, Point b2)
        {
            return isParallel(a1 - a2, b1 - b2);
        }
        static public bool isParallel(Segment s1, Segment s2)
        {
            return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
        }
        //16.3 射影
        static public Point project(Segment s, Point p)
        {
            Vector b = s.p2 - s.p1;
            double r = dot(p - s.p1, b) / b.norm();
            return s.p1 + b * r;
        }
        //16.4 反射
        static public Point reflection(Segment s, Point p)
        {
            return 2 * project(s, p) - p;
            //mid = project(s, p) - p;
            //return mid + mid - p;
        }
        //16.5 距離
        //2点間の距離
        static public double getDistance(Point a, Point b)
        {
            return (a - b).abs();
        }
        //直線lと点pの距離
        static public double getDistanceLP(Line l,Point p)
        {
            return Math.Abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs());
        }
        //線分sと点pの距離
        static public double getDistanceSP(Segment s, Point p)
        {
            if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs();
            if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs();
            return getDistanceLP(s, p);
        }
        static public double getDistance(Segment s1, Segment s2)
        {
            if (intersect(s1, s2)) return 0.0;
            return Math.Min(
                    Math.Min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),
                    Math.Min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))
                );
        }
        //16.6 反時計回り
        static public readonly int COUNTER_CLOCKWISE=1;
        static public readonly int CLOCKWISE = -1;
        static public readonly int ONLINE_BACK = 2;
        static public readonly int ONLINE_FRONT = -2;
        static public readonly int ON_SEGMENT = 0;
        static public int ccw(Point p0, Point p1, Point p2)
        {
            Vector a = p1 - p0;
            Vector b = p2 - p0;
            var dot_ = dot(a, b);
            var cross_ = cross(a, b);
            if (Consts.EPS < cross_) return COUNTER_CLOCKWISE;
            if (cross_ < -Consts.EPS) return CLOCKWISE;
            if (dot_ < -Consts.EPS) return ONLINE_BACK;
            if (a.norm() < b.norm()) return ONLINE_FRONT;
            return ON_SEGMENT;
        }
        static public int ccw(Segment s, Point p)
        {
            return ccw(s.p1, s.p2, p);

        }
        //16.7 線分の交差判定
        static public bool intersect(Point p1, Point p2,Point p3,Point p4)
        {
            return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
                ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0
                );
        }
        static public bool intersect(Segment s1, Segment s2)
        {
            return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
        }
        //16.8 線分の交点
        static public Point getCrossPoint(Segment s1, Segment s2)
        {
            Vector b = s2.p2 - s2.p1;
            double d1 = Math.Abs(cross(b, s1.p1 - s2.p1));
            double d2 = Math.Abs(cross(b, s1.p2 - s2.p1));
            double t = d1 / (d1 + d2);
            return s1.p1 + (s1.p2 - s1.p1) * t;
        }
        //16.9 円と直線の交点
        static public Segment getCrossPoints(Circle c, Line l)
        {
            Vector pr = project(l, c.c);
            System.Diagnostics.Debug.Assert((c.c - pr).abs() <= c.r);
            Vector e = (l.p2 - l.p1) / (l.p2 - l.p1).abs();
            double b = Math.Sqrt(c.r * c.r - (c.c - pr).norm());
            return new Segment(pr + e * b, pr - e * b);
        }
    }
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            var cr = Sarray();
            var c = new Circle(new Vector(cr[0], cr[1]), cr[2]);
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var l = Sarray();
                var line = new Line() { p1 = new Point(l[0], l[1]), p2 = new Point(l[2], l[3]) };
                var ans = VecCalc.getCrossPoints(c, line);
                var ans1 = ans.p1;
                var ans2 = ans.p2;
                if (ans1.X < ans2.X)
                { }
                else if (ans2.X < ans1.X)
                {
                    var tmp = ans1;
                    ans1 = ans2;
                    ans2 = tmp;
                }
                else if (ans2.Y < ans1.Y)
                {
                    var tmp = ans1;
                    ans1 = ans2;
                    ans2 = tmp;
                }
                WriteLine($"{ans1.X:F6} {ans1.Y:F6} {ans2.X:F6} {ans2.Y:F6}");
            }
        }
    }
}


Measured memory_bytes: 20504