using System;
using System.Linq;
using System.Text;

namespace CGL_7_D_CrossPointsofaCircleandaLine
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

			Circle circle = new Circle (inputNum[0], inputNum[1], inputNum[2]);

			int inputCount = int.Parse (Console.ReadLine ());
			StringBuilder output = new StringBuilder (inputCount * 10 * 2);

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] inputNum2 = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				Vector2 p1 = new Vector2 (inputNum2[0], inputNum2[1]);
				Vector2 p2 = new Vector2 (inputNum2[2], inputNum2[3]);

				Vector2[] result = Vector2.CrossPoint (p1, p2, circle).OrderBy (item => item.X).ThenBy (item => item.Y).ToArray ();

				output.Append (result[0].X); output.Append (" ");
				output.Append (result[0].Y); output.Append (" ");
				output.Append (result[1].X); output.Append (" ");
				output.Append (result[1].Y); output.AppendLine ();
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator + ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X + ob2.X, ob1.Y + ob2.Y);
		}
		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}
		public static Vector2 operator * ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X * scalar, ob.Y * scalar);
		}
		public static Vector2 operator / ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X / scalar, ob.Y / scalar);
		}
		private static decimal Sqrt ( decimal number )
		{
			return new decimal (Math.Sqrt (decimal.ToDouble (number)));
		}
		public decimal Length ()
		{
			return X * X + Y * Y;
		}
		public decimal Normalize ()
		{
			Vector2 tmp = new Vector2 (X, Y);
			return Sqrt (tmp.Length ());
		}
		public static decimal DotProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.X + line1.Y * line2.Y;
		}
		public static Vector2 Projection ( Vector2 beginPoint, Vector2 endPoint, Vector2 point )
		{
			Vector2 segment = endPoint - beginPoint;
			decimal ratio = Vector2.DotProduct (point - beginPoint, segment) / segment.Length ();
			return beginPoint + segment * ratio;
		}

		public static Vector2[] CrossPoint ( Vector2 beginPoint, Vector2 endPoint, Circle circle )
		{
			Vector2 projection = Vector2.Projection (beginPoint, endPoint, circle.Point);
			Vector2 normalize = (endPoint - beginPoint) / (endPoint - beginPoint).Normalize ();

			decimal verticalDistance = (projection - circle.Point).Length ();
			decimal length = Sqrt (circle.Radius * circle.Radius - verticalDistance);

			return new Vector2[] { 
				projection + normalize * length, 
				projection - normalize * length 
			};
		}
	}

	class Circle
	{
		public Circle ( decimal x, decimal y, decimal radius )
		{
			this.Point = new Vector2 (x, y);
			this.Radius = radius;
		}

		public Vector2 Point { private set; get; }
		public decimal Radius { private set; get; }
	}
}

Measured memory_bytes: 10392