For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.

Constraints

* $p1$ and $p2$ are different
* The circle and line have at least one cross point
* $1 \leq q \leq 1,000$
* $-10,000 \leq cx, cy, x1, y1, x2, y2 \leq 10,000$
* $1 \leq r \leq 10,000$

Input

The input is given in the following format.

$cx\; cy\; r$
$q$
$Line_1$
$Line_2$
:
$Line_q$


In the first line, the center coordinate of the circle and its radius are given by $cx$, $cy$ and $r$. In the second line, the number of queries $q$ is given.

In the following $q$ lines, as queries, $Line_i$ are given ($1 \leq i \leq q$) in the following format.

$x_1\; y_1\; x_2\; y_2$

Each line is represented by two points $p1$ and $p2$ which the line crosses. The coordinate of $p1$ and $p2$ are given by ($x1$, $y1$) and ($x2$, $y2$) respectively. All input values are given in integers.

Output

For each query, print the coordinates of the cross points in the following rules.

* If there is one cross point, print two coordinates with the same values.
* Print the coordinate with smaller $x$ first. In case of a tie, print the coordinate with smaller $y$ first.



The output values should be in a decimal fraction with an error less than 0.000001.

Example

Input

2 1 1
2
0 1 4 1
3 0 3 3


Output

1.00000000 1.00000000 3.00000000 1.00000000
3.00000000 1.00000000 3.00000000 1.00000000

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
def solve_eq(a, b, c):
	return ((-b - (b ** 2 - 4 * a * c) ** 0.5) / (2 * a), (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a))

def ret_line(x1, y1, x2, y2):
	k = (y1 - y2) / (x1 - x2)
	d = y1 - k * x1
	return (k, d)
(x, y, r) = map(float, input().split())
q = int(input())
(x1, y1, x2, y2) = ([], [], [], [])
for i in range(q):
	arr = list(map(float, input().split()))
	x1.append(arr[0])
	y1.append(arr[1])
	x2.append(arr[2])
	y2.append(arr[3])
for i in range(q):
	if x1[i] != x2[i]:
		(k, d) = ret_line(x1[i], y1[i], x2[i], y2[i])
		(p1, p2) = solve_eq(1 + k ** 2, 2 * k * d - 2 * k * y - 2 * x, x ** 2 + y ** 2 + d ** 2 - 2 * y * d - r ** 2)
		print(p1, k * p1 + d, p2, k * p2 + d)
	if x1[i] == x2[i]:
		(p1, p2) = solve_eq(1, -2 * y, y ** 2 + (x1[i] - x) ** 2 - r ** 2)
		print(x1[i], p1, x1[i], p2)


import math
import sys
from operator import attrgetter
from collections import namedtuple

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def get_cross_point(c, l):
	prj_vector = project(l, c.centre)
	line_unit_vector = (l.target - l.source) / abs(l.target - l.source)
	base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2))
	ans = [prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base]
	ans.sort(key=attrgetter('real', 'imag'))
	return ans

def solve(_lines):
	for line in _lines:
		line_axis = tuple(map(int, line))
		(p0, p1) = (x + y * 1j for (x, y) in zip(line_axis[::2], line_axis[1::2]))
		l = Segment(source=p0, target=p1)
		(cp1, cp2) = get_cross_point(circle, l)
		print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
	return None
_input = sys.stdin.readlines()
(cx, cy, r) = map(int, _input[0].split())
q_num = int(_input[1])
lines = map(lambda x: x.split(), _input[2:])
Circle = namedtuple('Circle', ('centre', 'radius'))
Segment = namedtuple('Segment', ('source', 'target'))
circle = Circle(centre=cx + cy * 1j, radius=r)
solve(lines)


(cx, cy, r) = map(int, input().split())
q = int(input())
for _ in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	(dx, dy) = (x2 - x1, y2 - y1)
	(px, py) = (cx - x1, cy - y1)
	s2 = dx ** 2 + dy ** 2
	dot = dx * px + dy * py
	crs = dx * py - dy * px
	t1 = (dot + (s2 * r ** 2 - crs ** 2) ** 0.5) / s2
	t2 = (dot - (s2 * r ** 2 - crs ** 2) ** 0.5) / s2
	if (dx < 0 or (dx == 0 and dy < 0)) ^ (t1 > t2):
		(t1, t2) = (t2, t1)
	print(x1 + dx * t1, y1 + dy * t1, x1 + dx * t2, y1 + dy * t2)


from functools import singledispatch
import math
EPS = 1e-10
COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

class Circle:

	def __init__(self, c, r):
		self.c = c
		self.r = r

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, point):
		return Point(self.x + point.x, self.y + point.y)

	def __sub__(self, point):
		return Point(self.x - point.x, self.y - point.y)

	def __mul__(self, a):
		return Point(a * self.x, a * self.y)

	def __truediv__(self, a):
		return Point(self.x / a, self.y / a)

	def __abs__(self):
		return math.sqrt(self.norm())

	def norm(self):
		return self.x ** 2 + self.y ** 2

	def __eq__(self, point):
		return abs(self.x - point.x) < EPS and abs(self.y - point.y) < EPS

def dot(a, b):
	return a.x * b.x + a.y * b.y

def cross(a, b):
	return a.x * b.y - a.y * b.x

def isOrthogonal(a, b):
	return dot(a, b) == 0

def isParallel(a, b):
	return cross(a, b) == 0

def project(s, p):
	base = s.p2 - s.p1
	r = dot(p - s.p1, base) / base.norm()
	return s.p1 + base * r

def reflect(s, p):
	return p + (project(s, p) - p) * 2

@singledispatch
def get_distance(a, b):
	return abs(a - b)

def get_distance_lp(l, p):
	return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1))

def get_distance_sp(s, p):
	if dot(s.p2 - s.p1, p - s.p1) < 0:
		return abs(p - s.p1)
	if dot(s.p1 - s.p2, p - s.p2) < 0:
		return abs(p - s.p2)
	return get_distance_lp(s, p)

@get_distance.register(Segment)
def _(s1, s2):
	if intersect(s1, s2):
		return 0
	return min([get_distance_sp(s1, s2.p1), get_distance_sp(s1, s2.p2), get_distance_sp(s2, s1.p1), get_distance_sp(s2, s1.p2)])

def ccw(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	if cross(a, b) > EPS:
		return COUNTER_CLOCKWISE
	if cross(a, b) < -EPS:
		return CLOCKWISE
	if dot(a, b) < -EPS:
		return ONLINE_BACK
	if a.norm() < b.norm():
		return ONLINE_FRONT
	return ON_SEGMENT

@singledispatch
def intersect(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

@intersect.register(Segment)
def _(s1, s2):
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2)

def get_cross_point(s1, s2):
	base = s2.p2 - s2.p1
	d1 = abs(cross(base, s1.p1 - s2.p1))
	d2 = abs(cross(base, s1.p2 - s2.p1))
	t = d1 / (d1 + d2)
	return s1.p1 + (s1.p2 - s1.p1) * t

def get_cross_points(c, l):
	pr = project(l, c.c)
	e = (l.p2 - l.p1) / abs(l.p2 - l.p1)
	base = (c.r ** 2 - (pr - c.c).norm()) ** 0.5
	return (pr + e * base, pr - e * base)
from sys import stdin
input = stdin.readline
(cx, cy, r) = map(int, input().split())
center = Point(cx, cy)
c = Circle(center, r)
q = int(input())
for _ in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	p1 = Point(x1, y1)
	p2 = Point(x2, y2)
	l = Segment(p1, p2)
	(ans1, ans2) = get_cross_points(c, l)
	for ans in [ans1, ans2]:
		if round(ans.x, 10) == 0:
			ans.x = 0
		if round(ans.y, 10) == 0:
			ans.y = 0
	if ans1.x < ans2.x or (ans1.x == ans2.x and ans1.y < ans2.y):
		print(ans1.x, ans1.y, ans2.x, ans2.y)
	else:
		print(ans2.x, ans2.y, ans1.x, ans1.y)


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Point(self.x * other, self.y * other)

	def __truediv__(self, other):
		return Point(self.x / other, self.y / other)

	def __repr__(self):
		return str(round(self.x, 8)) + ' ' + str(round(self.y, 8))

	def __lt__(self, other):
		if self.x == other.x:
			return self.y < other.y
		else:
			return self.x < other.x

class Vector(Point):
	pass

class Line:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

class Segment(Line):
	pass

class Circle:

	def __init__(self, c, r):
		self.c = c
		self.r = r

def points_to_vector(p1, p2):
	x = p1.x - p2.x
	y = p1.y - p2.y
	return Vector(x, y)

def vector(p):
	return Vector(p.x, p.y)

def dot(v1, v2):
	return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
	return v1.x * v2.y - v1.y * v2.x

def norm(v):
	return v.x ** 2 + v.y ** 2

def distance(v):
	return math.sqrt(norm(v))

def project(s, p):
	base = points_to_vector(s.p1, s.p2)
	hypo = points_to_vector(p, s.p1)
	r = dot(hypo, base) / norm(base)
	return s.p1 + base * r

def reflect(s, p):
	return p + (project(s, p) - p) * 2

def get_distance(s1, s2):
	if intersect_s(s1, s2):
		return 0
	d1 = get_distance_sp(s1, s2.p1)
	d2 = get_distance_sp(s1, s2.p2)
	d3 = get_distance_sp(s2, s1.p1)
	d4 = get_distance_sp(s2, s1.p2)
	return min(d1, min(d2, min(d3, d4)))

def get_distance_pp(p1, p2):
	return distance(p1 - p2)

def get_distance_lp(l, p):
	return abs(cross(l.p2 - l.p1, p - l.p1) / distance(l.p2 - l.p1))

def get_distance_sp(s, p):
	if dot(s.p2 - s.p1, p - s.p1) < 0:
		return distance(p - s.p1)
	elif dot(s.p1 - s.p2, p - s.p2) < 0:
		return distance(p - s.p2)
	else:
		return get_distance_lp(s, p)

def ccw(p0, p1, p2):
	EPS = 1e-10
	COUNTER_CLOCKWISE = 1
	CLOCKWISE = -1
	ONLINE_BACK = 2
	ONLINE_FRONT = -2
	ON_SEGMENT = 0
	v1 = p1 - p0
	v2 = p2 - p0
	if cross(v1, v2) > EPS:
		return COUNTER_CLOCKWISE
	elif cross(v1, v2) < -EPS:
		return CLOCKWISE
	elif dot(v1, v2) < -EPS:
		return ONLINE_BACK
	elif norm(v1) < norm(v2):
		return ONLINE_FRONT
	else:
		return ON_SEGMENT

def intersect_p(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect_s(s1, s2):
	return intersect_p(s1.p1, s1.p2, s2.p1, s2.p2)

def get_cross_point(s1, s2):
	base = s2.p2 - s2.p1
	d1 = abs(cross(base, s1.p1 - s2.p1))
	d2 = abs(cross(base, s1.p2 - s2.p1))
	t = d1 / (d1 + d2)
	return s1.p1 + (s1.p2 - s1.p1) * t

def get_cross_points(c, l):
	pr = project(l, c.c)
	e = (l.p2 - l.p1) / distance(l.p2 - l.p1)
	base = math.sqrt(c.r ** 2 - norm(pr - c.c))
	return (pr + e * base, pr - e * base)
import sys
temp = list(map(int, input().split()))
c = Circle(Point(temp[0], temp[1]), temp[2])
q = int(input())
for i in range(q):
	temp = list(map(int, input().split()))
	points = []
	for j in range(0, 4, 2):
		points.append(Point(temp[j], temp[j + 1]))
	l = Line(points[0], points[1])
	ans = get_cross_points(c, l)
	print(min(ans), max(ans))


import sys
import math

class Segment(object):
	__slots__ = ('source', 'target')

	def __init__(self, source, target):
		self.source = complex(source)
		self.target = complex(target)

class Circle(object):
	__slots__ = ('centre', 'radius')

	def __init__(self, centre, radius):
		self.centre = complex(centre)
		self.radius = float(radius)

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def get_cross_point(c, l):
	prj_vector = project(l, c.centre)
	line_unit_vector = (l.target - l.source) / abs(l.target - l.source)
	base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2))
	(p1, p2) = (prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base)
	if p1.real < p2.real:
		ans = (p1, p2)
	elif p1.real == p2.real:
		if p1.imag < p2.imag:
			ans = (p1, p2)
		else:
			ans = (p2, p1)
	else:
		ans = (p2, p1)
	return ans

def solve(_lines):
	for line in _lines:
		line_axis = tuple(map(int, line))
		(p0, p1) = (x + y * 1j for (x, y) in zip(line_axis[::2], line_axis[1::2]))
		l = Segment(p0, p1)
		(cp1, cp2) = get_cross_point(circle, l)
		print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
	return None
_input = sys.stdin.readlines()
(cx, cy, r) = map(int, _input[0].split())
q_num = int(_input[1])
lines = map(lambda x: x.split(), _input[2:])
circle = Circle(cx + cy * 1j, r)
solve(lines)


def dot(c1, c2):
	return c1.real * c2.real + c1.imag * c2.imag

def cross(c1, c2):
	return c1.real * c2.imag - c1.imag * c2.real

def project(p1, p2, p3):
	base = p2 - p1
	return p1 + base * dot(p3 - p1, base) / abs(base) ** 2

def print_cross_point(c, r, p1, p2):
	pr = project(p1, p2, c)
	l = p2 - p1
	e = l / abs(l)
	base = (r ** 2 - abs(pr - c) ** 2) ** 0.5
	c_p1 = pr - e * base
	c_p2 = pr + e * base
	print('{0:.10f} {1:.10f} {2:.10f} {3:.10f}'.format(c_p1.real, c_p1.imag, c_p2.real, c_p2.imag))
import sys
file_input = sys.stdin
(cx, cy, r) = map(int, file_input.readline().split())
c = cx + cy * 1j
q = file_input.readline()
for line in file_input:
	(x1, y1, x2, y2) = map(int, line.split())
	p1 = x1 + y1 * 1j
	p2 = x2 + y2 * 1j
	if x1 < x2:
		print_cross_point(c, r, p1, p2)
	elif x1 > x2 or y1 > y2:
		print_cross_point(c, r, p2, p1)
	else:
		print_cross_point(c, r, p1, p2)


from math import sqrt
EPS = 1e-08

def Projection(point, begin, end):
	tmp = (point - begin) / (end - begin)
	return tmp.real * (end - begin) + begin
(x, y, r) = map(int, input().split())
c = complex(x, y)
ans = []
q = int(input())
for _ in range(q):
	res = []
	(x, y, z, w) = map(int, input().split())
	(p1, p2) = (complex(x, y), complex(z, w))
	proj = Projection(c, p1, p2)
	for i in [-1, 1]:
		res.append(proj + i * sqrt(r ** 2 - abs(c - proj) ** 2) * (p2 - p1) / abs(p2 - p1))
	res.sort(key=lambda x: (x.real, x.imag))
	ans.append((res[0].real, res[0].imag, res[1].real, res[1].imag))
for a in ans:
	print('{:.10f} {:.10f} {:.10f} {:.10f}'.format(*a))


import math
import sys
from operator import attrgetter

class Segment(object):
	__slots__ = ('source', 'target')

	def __init__(self, source, target):
		self.source = complex(source)
		self.target = complex(target)

class Circle(object):
	__slots__ = ('centre', 'radius')

	def __init__(self, centre, radius):
		self.centre = complex(centre)
		self.radius = float(radius)

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def get_cross_point(c, l):
	prj_vector = project(l, c.centre)
	line_unit_vector = (l.target - l.source) / abs(l.target - l.source)
	base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2))
	ans = [prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base]
	ans.sort(key=attrgetter('real', 'imag'))
	return ans

def solve(_lines):
	for line in _lines:
		line_axis = tuple(map(int, line))
		(p0, p1) = (x + y * 1j for (x, y) in zip(line_axis[::2], line_axis[1::2]))
		l = Segment(p0, p1)
		(cp1, cp2) = get_cross_point(circle, l)
		print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
	return None
_input = sys.stdin.readlines()
(cx, cy, r) = map(int, _input[0].split())
q_num = int(_input[1])
lines = map(lambda x: x.split(), _input[2:])
circle = Circle(cx + cy * 1j, r)
solve(lines)


import math
EPS = 1e-10

def equals(a, b):
	return abs(a - b) < EPS

class Point:

	def __init__(self, x=0, y=0):
		self.x = x
		self.y = y

	def __add__(self, p):
		return Point(self.x + p.x, self.y + p.y)

	def __sub__(self, p):
		return Point(self.x - p.x, self.y - p.y)

	def __mul__(self, a):
		return Point(self.x * a, self.y * a)

	def __rmul__(self, a):
		return self * a

	def __truediv__(self, a):
		return Point(self.x / a, self.y / a)

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return math.sqrt(self.norm())

	def __lt__(self, p):
		if self.x != p.x:
			return self.x < p.x
		else:
			return self.y < p.y

	def __eq__(self, p):
		return equals(self.x, p.x) and equals(self.y, p.y)

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

class Circle:

	def __init__(self, c=Point(), r=0):
		self.c = c
		self.r = r

def dot(a, b):
	return a.x * b.x + a.y * b.y

def cross(a, b):
	return a.x * b.y - a.y * b.x

def project(s, p):
	base = s.p2 - s.p1
	r = dot(p - s.p1, base) / base.norm()
	return s.p1 + base * r

def getCrossPoint(c, l):
	pr = project(l, c.c)
	e = (l.p2 - l.p1) / (l.p2 - l.p1).abs()
	base = math.sqrt(c.r * c.r - (pr - c.c).norm())
	return (pr + e * base, pr - e * base)
(cx, cy, r) = [int(v) for v in input().split()]
c = Circle(Point(cx, cy), r)
q = int(input())
ans = []
for i in range(q):
	(x1, y1, x2, y2) = [int(v) for v in input().split()]
	l = Segment(Point(x1, y1), Point(x2, y2))
	(v1, v2) = getCrossPoint(c, l)
	if v2 < v1:
		(v1, v2) = (v2, v1)
	ans.append([v1.x, v1.y, v2.x, v2.y])
for v in ans:
	print('{0[0]:.8f} {0[1]:.8f} {0[2]:.8f} {0[3]:.8f}'.format(v))


import cmath
import itertools
import math
import os
import sys
from collections import defaultdict
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
PI = cmath.pi
TAU = cmath.pi * 2
EPS = 1e-10

class Point:
	CCW_COUNTER_CLOCKWISE = 1
	CCW_CLOCKWISE = -1
	CCW_ONLINE_BACK = 2
	CCW_ONLINE_FRONT = -2
	CCW_ON_SEGMENT = 0

	def __init__(self, c: complex):
		self.c = c

	@property
	def x(self):
		return self.c.real

	@property
	def y(self):
		return self.c.imag

	@staticmethod
	def from_rect(x: float, y: float):
		return Point(complex(x, y))

	@staticmethod
	def from_polar(r: float, phi: float):
		return Point(cmath.rect(r, phi))

	def __add__(self, p):
		return Point(self.c + p.c)

	def __iadd__(self, p):
		self.c += p.c
		return self

	def __sub__(self, p):
		return Point(self.c - p.c)

	def __isub__(self, p):
		self.c -= p.c
		return self

	def __mul__(self, f: float):
		return Point(self.c * f)

	def __imul__(self, f: float):
		self.c *= f
		return self

	def __truediv__(self, f: float):
		return Point(self.c / f)

	def __itruediv__(self, f: float):
		self.c /= f
		return self

	def __repr__(self):
		return '({}, {})'.format(round(self.x, 10), round(self.y, 10))

	def __neg__(self):
		return Point(-self.c)

	def __eq__(self, p):
		return abs(self.c - p.c) < EPS

	def __abs__(self):
		return abs(self.c)

	@staticmethod
	def ccw(a, b, c):
		b = b - a
		c = c - a
		det = b.det(c)
		if det > EPS:
			return Point.CCW_COUNTER_CLOCKWISE
		if det < -EPS:
			return Point.CCW_CLOCKWISE
		if b.dot(c) < -EPS:
			return Point.CCW_ONLINE_BACK
		if c.norm() - b.norm() > EPS:
			return Point.CCW_ONLINE_FRONT
		return Point.CCW_ON_SEGMENT

	def dot(self, p):
		return self.x * p.x + self.y * p.y

	def det(self, p):
		return self.x * p.y - self.y * p.x

	def dist(self, p):
		return abs(self.c - p.c)

	def norm(self):
		return abs(self.c)

	def phase(self):
		return cmath.phase(self.c)

	def angle(self, p, q):
		return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c) + PI) % TAU - PI

	def area(self, p, q):
		return abs((p - self).det(q - self) / 2)

	def projection_point(self, p, q, allow_outer=False):
		diff_q = q - p
		r = (self - p).dot(diff_q) / abs(diff_q)
		phase = diff_q.phase()
		ret = Point.from_polar(r, phase) + p
		if allow_outer or (p - ret).dot(q - ret) < EPS:
			return ret
		return None

	def reflection_point(self, p, q):
		r = abs(self - p)
		angle = p.angle(q, self)
		angle = (q - p).phase() - angle
		return Point.from_polar(r, angle) + p

	def on_segment(self, p, q, allow_side=True):
		if not allow_side and (self == p or self == q):
			return False
		return abs((p - self).det(q - self)) < EPS and (p - self).dot(q - self) < EPS

class Line:

	def __init__(self, a: float, b: float, c: float):
		self.a = a
		self.b = b
		self.c = c

	@staticmethod
	def from_gradient(grad: float, intercept: float):
		return Line(grad, -1, intercept)

	@staticmethod
	def from_segment(p1, p2):
		a = p2.y - p1.y
		b = p1.x - p2.x
		c = p2.y * (p2.x - p1.x) - p2.x * (p2.y - p1.y)
		return Line(a, b, c)

	@property
	def gradient(self):
		return INF if self.b == 0 else -self.a / self.b

	@property
	def intercept(self):
		return INF if self.b == 0 else -self.c / self.b

	def is_parallel_to(self, l):
		return abs(Point.from_rect(self.a, self.b).det(Point.from_rect(l.a, l.b))) < EPS

	def is_orthogonal_to(self, l):
		return abs(Point.from_rect(self.a, self.b).dot(Point.from_rect(l.a, l.b))) < EPS

	def intersection_point(self, l):
		(a1, b1, c1) = (self.a, self.b, self.c)
		(a2, b2, c2) = (l.a, l.b, l.c)
		det = a1 * b2 - a2 * b1
		if abs(det) < EPS:
			return None
		x = (b1 * c2 - b2 * c1) / det
		y = (a2 * c1 - a1 * c2) / det
		return Point.from_rect(x, y)

	def dist(self, p):
		raise NotImplementedError()

	def has_point(self, p):
		return abs(self.a * p.x + self.b * p.y + self.c) < EPS

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

	def norm(self):
		return abs(self.p1 - self.p2)

	def phase(self):
		return (self.p2 - self.p1).phase()

	def is_parallel_to(self, s):
		return abs((self.p1 - self.p2).det(s.p1 - s.p2)) < EPS

	def is_orthogonal_to(self, s):
		return abs((self.p1 - self.p2).dot(s.p1 - s.p2)) < EPS

	def intersects_with(self, s, allow_side=True):
		if self.is_parallel_to(s):
			return s.p1.on_segment(self.p1, self.p2, allow_side) or s.p2.on_segment(self.p1, self.p2, allow_side) or self.p1.on_segment(s.p1, s.p2, allow_side) or self.p2.on_segment(s.p1, s.p2, allow_side)
		else:
			det_upper = EPS if allow_side else -EPS
			ok = True
			ok &= (self.p2 - self.p1).det(s.p1 - self.p1) * (self.p2 - self.p1).det(s.p2 - self.p1) < det_upper
			ok &= (s.p2 - s.p1).det(self.p1 - s.p1) * (s.p2 - s.p1).det(self.p2 - s.p1) < det_upper
			return ok

	def closest_point(self, p):
		d = (p - self.p1).dot(self.p2 - self.p1) / self.norm()
		if d < EPS:
			return self.p1
		if -EPS < d - self.norm():
			return self.p2
		return Point.from_polar(d, (self.p2 - self.p1).phase()) + self.p1

	def dist(self, p):
		return abs(p - self.closest_point(p))

	def dist_segment(self, s):
		if self.intersects_with(s):
			return 0.0
		return min(self.dist(s.p1), self.dist(s.p2), s.dist(self.p1), s.dist(self.p2))

	def has_point(self, p, allow_side=True):
		return p.on_segment(self.p1, self.p2, allow_side=allow_side)

class Polygon:

	def __init__(self, points):
		self.points = points

	def iter2(self):
		return zip(self.points, self.points[1:] + self.points[:1])

	def iter3(self):
		return zip(self.points, self.points[1:] + self.points[:1], self.points[2:] + self.points[:2])

	def area(self):
		dets = []
		for (p, q) in self.iter2():
			dets.append(p.det(q))
		return abs(math.fsum(dets)) / 2

	def is_convex(self, allow_straight=False, allow_collapsed=False):
		ccw = []
		for (a, b, c) in self.iter3():
			ccw.append(Point.ccw(a, b, c))
		ccw = set(ccw)
		if len(ccw) == 1:
			if ccw == {Point.CCW_CLOCKWISE}:
				return True
			if ccw == {Point.CCW_COUNTER_CLOCKWISE}:
				return True
		if allow_straight and len(ccw) == 2:
			if ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_CLOCKWISE}:
				return True
			if ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_COUNTER_CLOCKWISE}:
				return True
		if allow_collapsed and len(ccw) == 3:
			return ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_ONLINE_BACK, Point.CCW_ON_SEGMENT}
		return False

	def has_point_on_edge(self, p):
		for (a, b) in self.iter2():
			if p.on_segment(a, b):
				return True
		return False

	def contains(self, p, allow_on_edge=True):
		angles = []
		for (a, b) in self.iter2():
			if p.on_segment(a, b):
				return allow_on_edge
			angles.append(p.angle(a, b))
		return abs(math.fsum(angles)) > EPS

	@staticmethod
	def convex_hull(points, allow_straight=False):
		points = points[:]
		points.sort(key=lambda p: (p.x, p.y))
		det_lower = -EPS if allow_straight else EPS
		sz = 0
		ret = [None] * (len(points) * 2)
		for p in points:
			while sz > 1 and (ret[sz - 1] - ret[sz - 2]).det(p - ret[sz - 1]) < det_lower:
				sz -= 1
			ret[sz] = p
			sz += 1
		floor = sz
		for p in reversed(points[:-1]):
			while sz > floor and (ret[sz - 1] - ret[sz - 2]).det(p - ret[sz - 1]) < det_lower:
				sz -= 1
			ret[sz] = p
			sz += 1
		ret = ret[:sz - 1]
		if allow_straight and len(ret) > len(points):
			ret = points
		return ret

	@staticmethod
	def diameter(points):
		points = Polygon.convex_hull(points, allow_straight=False)
		if len(points) == 1:
			return 0.0
		if len(points) == 2:
			return abs(points[0] - points[1])
		si = points.index(min(points, key=lambda p: (p.x, p.y)))
		sj = points.index(max(points, key=lambda p: (p.x, p.y)))
		n = len(points)
		ret = 0.0
		(i, j) = (si, sj)
		while i != sj or j != si:
			ret = max(ret, abs(points[i] - points[j]))
			ni = (i + 1) % n
			nj = (j + 1) % n
			if (points[ni] - points[i]).det(points[nj] - points[j]) > 0:
				j = nj
			else:
				i = ni
		return ret

	def convex_cut_by_line(self, line_p1, line_p2):
		n = len(self.points)
		line = Line.from_segment(line_p1, line_p2)
		on_line_points = []
		for (i, p) in enumerate(self.points):
			if line.has_point(p):
				on_line_points.append(i)
		has_on_line_edge = False
		if len(on_line_points) >= 3:
			has_on_line_edge = True
		elif len(on_line_points) == 2:
			has_on_line_edge = abs(on_line_points[0] - on_line_points[1]) in [1, n - 1]
		if has_on_line_edge:
			for p in self.points:
				ccw = Point.ccw(line_p1, line_p2, p)
				if ccw == Point.CCW_COUNTER_CLOCKWISE:
					return (Polygon(self.points[:]), None)
				if ccw == Point.CCW_CLOCKWISE:
					return (None, Polygon(self.points[:]))
		ret_lefts = []
		ret_rights = []
		d = line_p2 - line_p1
		for (p, q) in self.iter2():
			det_p = d.det(p - line_p1)
			det_q = d.det(q - line_p1)
			if det_p > -EPS:
				ret_lefts.append(p)
			if det_p < EPS:
				ret_rights.append(p)
			if det_p * det_q < -EPS:
				intersection = line.intersection_point(Line.from_segment(p, q))
				ret_lefts.append(intersection)
				ret_rights.append(intersection)
		l = Polygon(ret_lefts) if len(ret_lefts) > 1 else None
		r = Polygon(ret_rights) if len(ret_rights) > 1 else None
		return (l, r)

def closest_pair(points):
	assert len(points) >= 2

	def _rec(xsorted):
		n = len(xsorted)
		if n <= 2:
			return (xsorted[0].dist(xsorted[1]), (xsorted[0], xsorted[1]))
		if n <= 3:
			d = INF
			pair = None
			for (p, q) in itertools.combinations(xsorted, r=2):
				if p.dist(q) < d:
					d = p.dist(q)
					pair = (p, q)
			return (d, pair)
		(ld, lp) = _rec(xsorted[:n // 2])
		(rd, rp) = _rec(xsorted[n // 2:])
		if ld <= rd:
			d = ld
			ret_pair = lp
		else:
			d = rd
			ret_pair = rp
		mid_x = xsorted[n // 2].x
		mid_points = []
		for p in xsorted:
			if abs(p.x - mid_x) - d < -EPS:
				mid_points.append(p)
		mid_points.sort(key=lambda p: p.y)
		mid_n = len(mid_points)
		for i in range(mid_n - 1):
			j = i + 1
			p = mid_points[i]
			q = mid_points[j]
			while q.y - p.y - d < -EPS:
				pq_d = p.dist(q)
				if pq_d < d:
					d = pq_d
					ret_pair = (p, q)
				j += 1
				if j >= mid_n:
					break
				q = mid_points[j]
		return (d, ret_pair)
	return _rec(list(sorted(points, key=lambda p: p.x)))

def closest_pair_randomized(points):
	n = len(points)
	assert n >= 2
	if n == 2:
		return (points[0].dist(points[1]), (points[0], points[1]))
	import random
	points = points[:]
	random.shuffle(points)
	DELTA_XY = list(itertools.product([-1, 0, 1], repeat=2))
	grid = defaultdict(list)
	delta = INF
	dist = points[0].dist(points[1])
	ret_pair = (points[0], points[1])
	for i in range(2, n):
		if delta < EPS:
			return (0.0, ret_pair)
		if dist - delta < -EPS:
			delta = dist
			grid = defaultdict(list)
			for a in points[:i]:
				grid[a.x // delta, a.y // delta].append(a)
		else:
			p = points[i - 1]
			grid[p.x // delta, p.y // delta].append(p)
		p = points[i]
		dist = delta
		grid_x = p.x // delta
		grid_y = p.y // delta
		for (dx, dy) in DELTA_XY:
			for q in grid[grid_x + dx, grid_y + dy]:
				d = p.dist(q)
				if d - dist < -EPS:
					dist = d
					ret_pair = (p, q)
	return (min(delta, dist), ret_pair)

class Circle:

	def __init__(self, o, r):
		self.o = o
		self.r = r

	def __eq__(self, other):
		return self.o == other.o and abs(self.r - other.r) < EPS

	def ctc(self, c):
		if self.o == c.o:
			return INF if abs(self.r - c.r) < EPS else 0
		d = self.o.dist(c.o) - self.r - c.r
		if d > EPS:
			return 4
		elif d > -EPS:
			return 3
		elif d + min(self.r, c.r) * 2 > EPS:
			return 2
		elif d + min(self.r, c.r) * 2 > -EPS:
			return 1
		return 0

	def area(self):
		return self.r ** 2 * PI

	def intersection_point(self, s, allow_outer=False):
		projection_point = self.o.projection_point(s.p1, s.p2, allow_outer=True)
		dist = self.o.dist(projection_point)
		if dist - self.r > EPS:
			return []
		elif dist - self.r > -EPS:
			if allow_outer or s.has_point(projection_point):
				return [projection_point]
			else:
				return []
		diff = Point.from_polar(math.sqrt(self.r ** 2 - dist ** 2), s.phase())
		ret1 = projection_point + diff
		ret2 = projection_point - diff
		ret = []
		if allow_outer or s.has_point(ret1):
			ret.append(ret1)
		if allow_outer or s.has_point(ret2):
			ret.append(ret2)
		return ret
(x, y, r) = list(map(int, sys.stdin.buffer.readline().split()))
Q = int(sys.stdin.buffer.readline())
LINES = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(Q)]

def round_point(p):
	return (round(p.x, 8) + 0, round(p.y, 8) + 0)
circle = Circle(Point(complex(x, y)), r)
for (x1, y1, x2, y2) in LINES:
	ans = circle.intersection_point(Segment(Point(complex(x1, y1)), Point(complex(x2, y2))), allow_outer=True)
	if len(ans) == 1:
		(x, y) = round_point(ans[0])
		print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(x, y, x, y))
	elif len(ans) == 2:
		((x1, y1), (x2, y2)) = list(sorted(map(round_point, ans)))
		print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(x1, y1, x2, y2))
	else:
		assert False


from math import sqrt
from typing import List, Tuple

def project(point: complex, begin: complex, end: complex) -> complex:
	tmp = (point - begin) / (end - begin)
	return tmp.real * (end - begin) + begin
(x, y, r) = map(int, input().split())
c = complex(x, y)
ans: List[Tuple[float, float, float, float]] = []
q = int(input())
for _ in range(q):
	res = []
	(x, y, z, w) = map(int, input().split())
	(p1, p2) = (complex(x, y), complex(z, w))
	proj = project(c, p1, p2)
	for i in (-1, 1):
		res.append(proj + i * sqrt(r ** 2 - abs(c - proj) ** 2) * (p2 - p1) / abs(p2 - p1))
	res.sort(key=lambda x: (x.real, x.imag))
	ans.append((res[0].real, res[0].imag, res[1].real, res[1].imag))
for a in ans:
	print('{:.6f} {:.6f} {:.6f} {:.6f}'.format(*a))


import math

class Vector2:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, v):
		return Vector2(self.x + v.x, self.y + v.y)

	def __sub__(self, v):
		return Vector2(self.x - v.x, self.y - v.y)

	def __mul__(self, v):
		return Vector2(self.x * v, self.y * v)

	def __truediv__(self, v):
		return Vector2(self.x / v, self.y / v)

	def __abs__(self):
		return math.sqrt(float(self.x * self.x + self.y * self.y))

	def __str__(self):
		return f'({self.x},{self.y})'

	def __lt__(self, v):
		if math.isclose(self.x, v.x):
			return self.y < v.y
		return self.x < v.x

	def dot(self, v):
		return self.x * v.x + self.y * v.y

	def cross(self, v):
		return self.x * v.y - self.y * v.x

	def norm(self):
		d = abs(self)
		return Vector2(self.x / d, self.y / d)

def projection(v1, v2, p):
	v12 = (v2 - v1).norm()
	v1p = p - v1
	d = v12.dot(v1p)
	return v1 + v12 * d

def distanceLP(v1, v2, p):
	return abs((v2 - v1).cross(p - v1)) / abs(v2 - v1)

def distanceSP(v1, v2, p):
	if (v2 - v1).dot(p - v1) < 0.0:
		return abs(p - v1)
	if (v1 - v2).dot(p - v2) < 0.0:
		return abs(p - v2)
	return distanceLP(v1, v2, p)

def ccw(p0, p1, p2):
	c = (p1 - p0).cross(p2 - p0)
	if math.isclose(c, 0.0, abs_tol=1e-10):
		d = (p1 - p0).dot(p2 - p0)
		if d < 0.0:
			return -1
		else:
			d1 = abs(p1 - p0)
			d2 = abs(p2 - p0)
			if d1 < d2:
				return 1
			else:
				return 0
	elif c < 0.0:
		return -1
	else:
		return 1

def intersect(p1, p2, p3, p4):
	c1 = ccw(p1, p2, p3) * ccw(p1, p2, p4)
	c2 = ccw(p3, p4, p1) * ccw(p3, p4, p2)
	return c1 <= 0.0 and c2 <= 0.0

def distance(a1, a2, b1, b2):
	if intersect(a1, a2, b1, b2):
		return 0.0
	return min([min([distanceSP(a1, a2, b1), distanceSP(a1, a2, b2)]), min([distanceSP(b1, b2, a1), distanceSP(b1, b2, a2)])])
(cx, cy, r) = map(int, input().split())
p = Vector2(cx, cy)
q = int(input())
for i in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	(v1, v2) = (Vector2(x1, y1), Vector2(x2, y2))
	pr = projection(v1, v2, p)
	e = (v2 - v1) / abs(v2 - v1)
	base = math.sqrt(r * r - abs(pr - p) ** 2)
	(a1, a2) = (pr + e * base, pr - e * base)
	ans = ''
	for a in sorted([a1, a2]):
		ans += f'{a.x:.10f} {a.y:.10f} '
	print(ans.strip())


from sys import stdin
import math

class Vector:

	def __init__(self, x=None, y=None):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, k):
		return Vector(self.x * k, self.y * k)

	def __truediv__(self, k):
		return Vector(self.x / k, self.y / k)

	def __gt__(self, other):
		return self.x > other.x and self.y > other.yb

	def __lt__(self, other):
		return self.x < other.x and self.y < other.yb

	def __eq__(self, other):
		return self.x == other.x and self.y == other.y

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return math.sqrt(self.norm())

class Point(Vector):

	def __init__(self, *args, **kargs):
		return super().__init__(*args, **kargs)

class Segment:

	def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
		self.p1 = p1
		self.p2 = p2

class Line(Segment):

	def __init__(self, *args, **kargs):
		return super().__init__(*args, **kargs)

class Circle:

	def __init__(self, c=Point(0, 0), r=1):
		self.c = c
		self.r = r

def project(s, p):
	base = s.p2 - s.p1
	hypo = p - s.p1
	r = hypo.dot(base) / base.norm()
	return s.p1 + base * r

def get_cross_point(c, l):
	pr = project(l, c.c)
	e = (l.p1 - l.p2) / (l.p2 - l.p1).abs()
	base = math.sqrt(c.r * c.r - (pr - c.c).norm())
	return (pr + e * base, pr - e * base)

def read_and_print_results(n, c):
	for _ in range(n):
		line = stdin.readline().strip().split()
		p0 = Vector(int(line[0]), int(line[1]))
		p1 = Vector(int(line[2]), int(line[3]))
		l = Line(p0, p1)
		(p2, p3) = get_cross_point(c, l)
		(x1, y1) = min((p2.x, p2.y), (p3.x, p3.y))
		(x2, y2) = max((p2.x, p2.y), (p3.x, p3.y))
		print('{0:0.8f} {1:0.8f} {2:0.8f} {3:0.8f}'.format(x1, y1, x2, y2))
(x, y, r) = [int(i) for i in input().split()]
c = Circle(Point(x, y), r)
n = int(input())
read_and_print_results(n, c)


import sys
import math

class Segment(object):
	__slots__ = ('source', 'target')

	def __init__(self, source, target):
		self.source = complex(source)
		self.target = complex(target)

class Circle(object):
	__slots__ = ('centre', 'radius')

	def __init__(self, x, y, r):
		self.centre = x + y * 1j
		self.radius = r

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def get_cross_point(c, l):
	prj_vector = project(l, c.centre)
	line_unit_vector = (l.target - l.source) / abs(l.target - l.source)
	base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2))
	(p1, p2) = (prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base)
	if p1.real < p2.real:
		ans = (p1, p2)
	elif p1.real == p2.real:
		if p1.imag < p2.imag:
			ans = (p1, p2)
		else:
			ans = (p2, p1)
	else:
		ans = (p2, p1)
	return ans

def solve(_lines):
	for line in _lines:
		line_axis = tuple(map(int, line))
		(p0, p1) = (x + y * 1j for (x, y) in zip(line_axis[::2], line_axis[1::2]))
		l = Segment(p0, p1)
		(cp1, cp2) = get_cross_point(circle, l)
		print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
	return None
_input = sys.stdin.readlines()
(cx, cy, radius) = map(int, _input[0].split())
q_num = int(_input[1])
lines = map(lambda x: x.split(), _input[2:])
circle = Circle(cx, cy, radius)
solve(lines)


import sys
from itertools import starmap
import math
readline = sys.stdin.readline
EPS = 1e-09
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2

class Circle(object):
	__slots__ = ('c', 'r')

	def __init__(self, c, r):
		self.c = c
		self.r = r

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se
Line = Segment

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r

def reflect(s, p):
	return p + (project(s, p) - p) * 2.0

def ccw(p1, p2, p3):
	a = p2 - p1
	b = p3 - p1
	if cross(a, b) > EPS:
		return 1
	if cross(a, b) < -EPS:
		return -1
	if dot(a, b) < -EPS:
		return 2
	if norm(a) < norm(b):
		return -2
	return 0

def intersect4(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect2(s1, s2):
	return intersect4(s1.fi, s1.se, s2.fi, s2.se)

def getDistance(a, b):
	return abs(a - b)

def getDistanceLP(l, p):
	return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))

def getDistanceSP(s, p):
	if dot(s.se - s.fi, p - s.fi) < 0.0:
		return abs(p - s.fi)
	if dot(s.fi - s.se, p - s.se) < 0.0:
		return abs(p - s.se)
	return getDistanceLP(s, p)

def getDistances(s1, s2):
	if intersect2(s1, s2):
		return 0.0
	return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se), getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))

def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t

def getCrossPoints(c, l):
	pr = project(l, c.c)
	e = (l.se - l.fi) / abs(l.se - l.fi)
	base = math.sqrt(c.r * c.r - norm(pr - c.c))
	return Segment(pr + e * base, pr - e * base)
(x, y, r) = map(int, readline().split())
ci = Circle(complex(x, y), r)
n = int(readline())
for _ in [0] * n:
	(p0, p1) = starmap(complex, zip(*[map(int, readline().split())] * 2))
	ppp = getCrossPoints(ci, Line(p0, p1))
	if ppp.se.real < ppp.fi.real or (ppp.se.real == ppp.fi.real and ppp.se.imag < ppp.fi.imag):
		(ppp.fi, ppp.se) = (ppp.se, ppp.fi)
	print(*map('{:.10f}'.format, [ppp.fi.real, ppp.fi.imag, ppp.se.real, ppp.se.imag]))


import sys
from operator import itemgetter, attrgetter
from itertools import starmap
import math
readline = sys.stdin.readline
EPS = 1e-09
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2

class Circle(object):
	__slots__ = ('c', 'r')

	def __init__(self, c, r):
		self.c = c
		self.r = r

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se
Line = Segment

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r

def reflect(s, p):
	return p + (project(s, p) - p) * 2.0

def ccw(p1, p2, p3):
	a = p2 - p1
	b = p3 - p1
	if cross(a, b) > EPS:
		return 1
	if cross(a, b) < -EPS:
		return -1
	if dot(a, b) < -EPS:
		return 2
	if norm(a) < norm(b):
		return -2
	return 0

def intersect4(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect2(s1, s2):
	return intersect4(s1.fi, s1.se, s2.fi, s2.se)

def getDistance(a, b):
	return abs(a - b)

def getDistanceLP(l, p):
	return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))

def getDistanceSP(s, p):
	if dot(s.se - s.fi, p - s.fi) < 0.0:
		return abs(p - s.fi)
	if dot(s.fi - s.se, p - s.se) < 0.0:
		return abs(p - s.se)
	return getDistanceLP(s, p)

def getDistances(s1, s2):
	if intersect2(s1, s2):
		return 0.0
	return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se), getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))

def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t

def getCrossPoints(c, l):
	pr = project(l, c.c)
	e = (l.se - l.fi) / abs(l.se - l.fi)
	base = math.sqrt(c.r * c.r - norm(pr - c.c))
	return Segment(*sorted((pr + e * base, pr - e * base), key=attrgetter('real', 'imag')))
(x, y, r) = map(int, readline().split())
ci = Circle(complex(x, y), r)
n = int(readline())
for _ in [0] * n:
	(p0, p1) = starmap(complex, zip(*[map(int, readline().split())] * 2))
	ppp = getCrossPoints(ci, Line(p0, p1))
	print(*map('{:.10f}'.format, (ppp.fi.real, ppp.fi.imag, ppp.se.real, ppp.se.imag)))


import sys
sys.setrecursionlimit(10 ** 9)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
INF = float('inf')

class Geometry:
	EPS = 10 ** (-9)

	def add(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return (x1 + x2, y1 + y2)

	def sub(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return (x1 - x2, y1 - y2)

	def mul(self, a, b):
		(x1, y1) = a
		if not isinstance(b, tuple):
			return (x1 * b, y1 * b)
		(x2, y2) = b
		return (x1 * x2, y1 * y2)

	def div(self, a, b):
		(x1, y1) = a
		if not isinstance(b, tuple):
			return (x1 / b, y1 / b)
		(x2, y2) = b
		return (x1 / x2, y1 / y2)

	def abs(self, a):
		from math import hypot
		(x1, y1) = a
		return hypot(x1, y1)

	def norm(self, a):
		(x, y) = a
		return x ** 2 + y ** 2

	def dot(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return x1 * x2 + y1 * y2

	def cross(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return x1 * y2 - y1 * x2

	def project(self, seg, p):
		(p1, p2) = seg
		base = self.sub(p2, p1)
		r = self.dot(self.sub(p, p1), base) / self.norm(base)
		return self.add(p1, self.mul(base, r))

	def reflect(self, seg, p):
		return self.add(p, self.mul(self.sub(self.project(seg, p), p), 2))

	def ccw(self, p0, p1, p2):
		a = self.sub(p1, p0)
		b = self.sub(p2, p0)
		if self.cross(a, b) > self.EPS:
			return 1
		if self.cross(a, b) < -self.EPS:
			return -1
		if self.dot(a, b) < -self.EPS:
			return 2
		if self.norm(a) < self.norm(b):
			return -2
		return 0

	def intersect(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		return self.ccw(p1, p2, p3) * self.ccw(p1, p2, p4) <= 0 and self.ccw(p3, p4, p1) * self.ccw(p3, p4, p2) <= 0

	def get_distance_LP(self, line, p):
		(p1, p2) = line
		return abs(self.cross(self.sub(p2, p1), self.sub(p, p1)) / self.abs(self.sub(p2, p1)))

	def get_distance_SP(self, seg, p):
		(p1, p2) = seg
		if self.dot(self.sub(p2, p1), self.sub(p, p1)) < 0:
			return self.abs(self.sub(p, p1))
		if self.dot(self.sub(p1, p2), self.sub(p, p2)) < 0:
			return self.abs(self.sub(p, p2))
		return self.get_distance_LP(seg, p)

	def get_distance_SS(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		if self.intersect(seg1, seg2):
			return 0
		return min(self.get_distance_SP(seg1, p3), self.get_distance_SP(seg1, p4), self.get_distance_SP(seg2, p1), self.get_distance_SP(seg2, p2))

	def get_cross_pointSS(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		base = self.sub(p4, p3)
		dist1 = abs(self.cross(base, self.sub(p1, p3)))
		dist2 = abs(self.cross(base, self.sub(p2, p3)))
		t = dist1 / (dist1 + dist2)
		return self.add(p1, self.mul(self.sub(p2, p1), t))

	def get_cross_pointCL(self, c, line):
		from math import sqrt
		(x, y, r) = c
		(p1, p2) = line
		pr = self.project(line, (x, y))
		e = self.div(self.sub(p2, p1), self.abs(self.sub(p2, p1)))
		base = sqrt(r * r - self.norm(self.sub(pr, (x, y))))
		return [self.add(pr, self.mul(e, base)), self.sub(pr, self.mul(e, base))]
gm = Geometry()
(x, y, r) = MAP()
c = (x, y, r)
for _ in range(INT()):
	(x1, y1, x2, y2) = MAP()
	seg = ((x1, y1), (x2, y2))
	res = gm.get_cross_pointCL(c, seg)
	res.sort()
	res = sum(res, ())
	for i in range(3):
		print('{:.10f}'.format(res[i]), end=' ')
	print('{:.10f}'.format(res[-1]))


import collections
import math

class Vector2(collections.namedtuple('Vector2', ['x', 'y'])):

	def __add__(self, other):
		return Vector2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector2(self.x - other.x, self.y - other.y)

	def __mul__(self, scalar):
		return Vector2(self.x * scalar, self.y * scalar)

	def __neg__(self):
		return Vector2(-self.x, -self.y)

	def __pos__(self):
		return Vector2(+self.x, +self.y)

	def __abs__(self):
		return math.sqrt(float(self.x * self.x + self.y * self.y))

	def __truediv__(self, scalar):
		return Vector2(self.x / scalar, self.y / scalar)

	def abs2(self):
		return float(self.x * self.x + self.y * self.y)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

def getDistanceSP(segment, point):
	p = point
	(p1, p2) = segment
	if (p2 - p1).dot(p - p1) < 0:
		return abs(p - p1)
	if (p1 - p2).dot(p - p2) < 0:
		return abs(p - p2)
	return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)

def getDistance(s1, s2):
	(a, b) = s1
	(c, d) = s2
	if intersect(s1, s2):
		return 0
	return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))

def ccw(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	if a.cross(b) > 0:
		return 1
	elif a.cross(b) < 0:
		return -1
	elif a.dot(b) < 0:
		return 2
	elif abs(a) < abs(b):
		return -2
	else:
		return 0

def intersect(s1, s2):
	(a, b) = s1
	(c, d) = s2
	return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0

def project(l, p):
	(p1, p2) = l
	base = p2 - p1
	hypo = p - p1
	return p1 + base * (hypo.dot(base) / abs(base) ** 2)

class Circle:

	def __init__(self, c, r):
		self.c = c
		self.r = r

def getCrossPoints(c, l):
	pr = project(l, c.c)
	(p1, p2) = l
	e = (p2 - p1) / abs(p2 - p1)
	base = math.sqrt(c.r * c.r - (pr - c.c).abs2())
	return [pr + e * base, pr - e * base]
(a, b, r) = map(int, input().split())
c = Circle(Vector2(a, b), r)
n = int(input())
res = []
for _ in range(n):
	ps = list(map(int, input().split()))
	l = [Vector2(ps[0], ps[1]), Vector2(ps[2], ps[3])]
	ans = getCrossPoints(c, l)
	ans = sorted(ans, key=lambda x: (x.x, x.y))
	res.append(ans)
for ans in res:
	print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(ans[0].x, ans[0].y, ans[1].x, ans[1].y))


from sys import stdin
readline = stdin.readline

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def unit(a):
	return a / abs(a)

def near_pos_online(p, a, b):
	unit_a_b = unit(b - a)
	dist_from_a = dot(unit_a_b, p - a)
	return a + unit_a_b * dist_from_a

def intersection_of_circle_and_line(center, r, a, b):
	near = near_pos_online(center, a, b)
	d = sqrt(r ** 2 - abs(center - near) ** 2) * unit(b - a)
	return [near + d, near - d]
from math import sqrt
from operator import attrgetter

def main():
	(cx, cy, r) = map(int, readline().split())
	center = complex(cx, cy)
	q = int(readline())
	for i in range(q):
		(x1, y1, x2, y2) = map(int, readline().split())
		(a, b) = (complex(x1, y1), complex(x2, y2))
		intersection = intersection_of_circle_and_line(center, r, a, b)
		intersection.sort(key=attrgetter('real', 'imag'))
		(pre, post) = intersection
		print(*list(map('{:.6f}'.format, [pre.real, pre.imag, post.real, post.imag])))
main()


import math

class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, scalar):
		return Vector(self.x * scalar, self.y * scalar)

	def __rmul__(self, scalar):
		return Vector(self.x * scalar, self.y * scalar)

	def __repr__(self):
		return str([self.x, self.y])

	def norm_2(self):
		return dot(self, self)

	def norm(self):
		return math.sqrt(self.norm_2())

def v_sum(v1, v2):
	return Vector(v1.x + v2.x, v1.y + v2.y)

def scalar_multi(k, v):
	return Vector(k * v.x, k * v.y)

def v_diff(v1, v2):
	return v_sum(v1, scalar_multi(-1, v2))

def dot(vector1, vector2):
	return vector1.x * vector2.x + vector1.y * vector2.y

def cross(vector1, vector2):
	return vector1.x * vector2.y - vector1.y * vector2.x
(cx, cy, r) = map(int, input().split())
c = Vector(cx, cy)
q = int(input())
for i in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	p1 = Vector(x1, y1)
	p2 = Vector(x2, y2)
	d = p2 - p1
	m = p1 + dot(c - p1, d) / d.norm_2() * d
	l = math.sqrt(r ** 2 - (m - c).norm_2())
	a = m - l / d.norm() * d
	b = m + l / d.norm() * d
	if abs(a.x) < 10 ** (-9):
		a.x = 0
	if abs(a.y) < 10 ** (-9):
		a.y = 0
	if abs(b.x) < 10 ** (-9):
		b.x = 0
	if abs(b.y) < 10 ** (-9):
		b.y = 0
	if a.x < b.x:
		print('{} {} {} {}'.format(a.x, a.y, b.x, b.y))
	elif a.x > b.x:
		print('{} {} {} {}'.format(b.x, b.y, a.x, a.y))
	elif a.y < b.y:
		print('{} {} {} {}'.format(a.x, a.y, b.x, b.y))
	else:
		print('{} {} {} {}'.format(b.x, b.y, a.x, a.y))


from math import pi, cos, sin, atan2
EPS = 10 ** (-9)

def eq(value1, value2):
	return abs(value1 - value2) <= EPS

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.arg = atan2(y, x)

	def __str__(self):
		return '{0:.8f} {1:.8f}'.format(self.x, self.y)

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, scal):
		return Point(self.x * scal, self.y * scal)

	def __truediv__(self, scal):
		return Point(self.x / scal, self.y / scal)

	def __eq__(self, other):
		return eq(self.x, other.x) and eq(self.y, other.y)

	def __abs__(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

def Rotation(vec: Point, rad):
	return Point(vec.x * cos(rad) - vec.y * sin(rad), vec.x * sin(rad) + vec.y * cos(rad))

class Circle:

	def __init__(self, p, r):
		self.p = p
		self.r = r

class Line:

	def __init__(self, a, b):
		self.a = a
		self.b = b
		self.arg = (a - b).arg % pi

	def __str__(self):
		return '[({0}, {1}) - ({2}, {3})]'.format(self.a.x, self.a.y, self.b.x, self.b.y)

	def par(self, point):
		return Line(point, point + (self.a - self.b))

	def tan(self, point):
		return Line(point, point + Rotation(self.a - self.b, pi / 2))

class Segment(Line):

	def __init__(self, a, b):
		super().__init__(a, b)

def cross(vec1: Point, vec2: Point):
	return vec1.x * vec2.y - vec1.y * vec2.x

def dot(vec1: Point, vec2: Point):
	return vec1.x * vec2.x + vec1.y * vec2.y

def ccw(a, b, c):
	if cross(b - a, c - a) > EPS:
		return +1
	if cross(b - a, c - a) < -EPS:
		return -1
	if dot(c - a, b - a) < -EPS:
		return +2
	if abs(b - a) < abs(c - a):
		return -2
	return 0

def projection(l, p):
	t = dot(l.b - l.a, p - l.a) / abs(l.a - l.b) ** 2
	return l.a + (l.b - l.a) * t

def reflection(l, p):
	return p + (projection(l, p) - p) * 2

def isPararell(l1, l2):
	return eq(cross(l1.a - l1.b, l2.a - l2.b), 0)

def isVertical(l1, l2):
	return eq(dot(l1.a - l1.b, l2.a - l2.b), 0)

def isIntersect_lp(l, p):
	return abs(ccw(l.a, l.b, p)) != 1

def isIntersect_ll(l1, l2):
	return not isPararell(l1, l2) or isIntersect_lp(l1, l2.a)

def isIntersect_sp(s, p):
	return ccw(s.a, s.b, p) == 0

def isIntersect_ss(s1, s2):
	return ccw(s1.a, s1.b, s2.a) * ccw(s1.a, s1.b, s2.b) <= 0 and ccw(s2.a, s2.b, s1.a) * ccw(s2.a, s2.b, s1.b) <= 0

def isIntersect_ls(l, s):
	return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS

def isIntersect_cp(c, p):
	return abs(abs(c.p - p) - c.r) < EPS

def isIntersect_cl(c, l):
	return distance_lp(l, c.p) <= c.r + EPS

def isIntersect_cs(c, s):
	pass

def intersect_cc(c1, c2):
	if c1.r < c2.r:
		(c1, c2) = (c2, c1)
	d = abs(c1.p - c2.p)
	if eq(c1.r + c2.r, d):
		return 3
	if eq(c1.r - c2.r, d):
		return 1
	if c1.r + c2.r < d:
		return 4
	if c1.r - c2.r < d:
		return 2
	return 0

def distance_pp(p1, p2):
	return abs(p1 - p2)

def distance_lp(l, p):
	return abs(projection(l, p) - p)

def distance_ll(l1, l2):
	return 0 if isIntersect_ll(l1, l2) else distance_lp(l1, l2.a)

def distance_sp(s, p):
	r = projection(s, p)
	if isIntersect_sp(s, r):
		return abs(r - p)
	return min(abs(s.a - p), abs(s.b - p))

def distance_ss(s1, s2):
	if isIntersect_ss(s1, s2):
		return 0
	return min([distance_sp(s1, s2.a), distance_sp(s1, s2.b), distance_sp(s2, s1.a), distance_sp(s2, s1.b)])

def distance_ls(l, s):
	if isIntersect_ls(l, s):
		return 0
	return min(distance_lp(l, s.a), distance_lp(l, s.b))

def crosspoint_ll(l1, l2):
	A = cross(l1.b - l1.a, l2.b - l2.a)
	B = cross(l1.b - l1.a, l1.b - l2.a)
	if eq(abs(A), 0) and eq(abs(B), 0):
		return l2.a
	return l2.a + (l2.b - l2.a) * B / A

def crosspoint_ss(s1, s2):
	return crosspoint_ll(s1, s2)

def crosspoint_lc(l, c):
	p = projection(l, c.p)
	if eq(distance_lp(l, c.p), c.r):
		return [p]
	e = (l.b - l.a) / abs(l.b - l.a)
	dis = (c.r ** 2 - abs(p - c.p) ** 2) ** 0.5
	return [p + e * dis, p - e * dis]

def crosspoint_sc(s, c):
	pass

def crosspoint_cc(c1, c2):
	d = abs(c1.p - c2.p)
	if not abs(c1.r - c2.r) <= d <= c1.r + c2.r:
		return []
	mid_p = (c2.p * (c1.r ** 2 - c2.r ** 2 + d ** 2) + c1.p * (c2.r ** 2 - c1.r ** 2 + d ** 2)) / (2 * d ** 2)
	tanvec = Rotation(c1.p - c2.p, pi / 2)
	return crosspoint_lc(Line(mid_p, mid_p + tanvec), c1)

def tangent_cp(c, p):
	return crosspoint_cc(c, Circle(p, (abs(p - c.p) ** 2 - c.r ** 2) ** 0.5))
import sys
input = sys.stdin.readline

def verify_1A():
	(p1x, p1y, p2x, p2y) = map(int, input().split())
	l = Line(Point(p1x, p1y), Point(p2x, p2y))
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (px, py) in Query:
		p = Point(px, py)
		print(projection(l, p))

def verify_1B():
	(p1x, p1y, p2x, p2y) = map(int, input().split())
	l = Line(Point(p1x, p1y), Point(p2x, p2y))
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (px, py) in Query:
		p = Point(px, py)
		print(reflection(l, p))

def verify_1C():
	(p1x, p1y, p2x, p2y) = map(int, input().split())
	p1 = Point(p1x, p1y)
	p2 = Point(p2x, p2y)
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (px, py) in Query:
		p = Point(px, py)
		result = ccw(p1, p2, p)
		if result == 1:
			print('COUNTER_CLOCKWISE')
		elif result == -1:
			print('CLOCKWISE')
		elif result == 2:
			print('ONLINE_BACK')
		elif result == -2:
			print('ONLINE_FRONT')
		else:
			print('ON_SEGMENT')

def verify_2A():
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) in Query:
		l1 = Line(Point(p0x, p0y), Point(p1x, p1y))
		l2 = Line(Point(p2x, p2y), Point(p3x, p3y))
		if isPararell(l1, l2):
			print(2)
		elif isVertical(l1, l2):
			print(1)
		else:
			print(0)

def verify_2B():
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) in Query:
		s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
		s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
		if isIntersect_ss(s1, s2):
			print(1)
		else:
			print(0)

def verify_2C():
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) in Query:
		s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
		s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
		print(crosspoint_ss(s1, s2))

def verify_2D():
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) in Query:
		s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
		s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
		print('{:.8f}'.format(distance_ss(s1, s2)))

def verify_7A():
	(c1x, c1y, c1r) = map(int, input().split())
	(c2x, c2y, c2r) = map(int, input().split())
	print(intersect_cc(Circle(Point(c1x, c1y), c1r), Circle(Point(c2x, c2y), c2r)))

def verify_7D():
	(cx, cy, cr) = map(int, input().split())
	c = Circle(Point(cx, cy), cr)
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (x1, y1, x2, y2) in Query:
		Points = crosspoint_lc(Line(Point(x1, y1), Point(x2, y2)), c)
		if len(Points) == 1:
			Points.append(Points[-1])
		Points.sort(key=lambda p: p.y)
		Points.sort(key=lambda p: p.x)
		print(*Points)
verify_7D()


EPS = 1e-10
COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Point:
	global EPS

	def __init__(self, x=0, y=0):
		self.x = x
		self.y = y

	def __add__(a, b):
		s = a.x + b.x
		t = a.y + b.y
		return Point(s, t)

	def __sub__(a, b):
		s = a.x - b.x
		t = a.y - b.y
		return Point(s, t)

	def __mul__(self, a):
		s = a * self.x
		t = a * self.y
		return Point(s, t)

	def __truediv__(self, a):
		s = self.x / a
		t = self.y / a
		return Point(s, t)

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return self.norm() ** 0.5

	def __eq__(self, other):
		return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS

	def dot(self, b):
		return self.x * b.x + self.y * b.y

	def cross(self, b):
		return self.x * b.y - self.y * b.x

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

class Circle:

	def __init__(self, c, r):
		self.c = c
		self.r = r

def project(s, p):
	base = s.p2 - s.p1
	hypo = p - s.p1
	r = hypo.dot(base) / base.norm()
	return s.p1 + base * r

def reflecton(s, p):
	return p + (project(s, p) - p) * 2

def getDistance(a, b):
	return (a - b).abs()

def getDistanceLP(l, p):
	return abs((l.p2 - l.p1).cross(p - l.p1)) / (l.p2 - l.p1).abs()

def getDistanceSP(s, p):
	if (s.p2 - s.p1).dot(p - s.p1) < 0:
		return (p - s.p1).abs()
	elif (s.p1 - s.p2).dot(p - s.p2) < 0:
		return (p - s.p2).abs()
	return getDistanceLP(s, p)

def getDistanceSS(s1, s2):
	if intersectS(s1, s2):
		return 0
	return min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))

def ccw(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	if a.cross(b) > 0:
		return COUNTER_CLOCKWISE
	elif a.cross(b) < 0:
		return CLOCKWISE
	elif a.dot(b) < 0:
		return ONLINE_BACK
	elif a.abs() < b.abs():
		return ONLINE_FRONT
	else:
		return ON_SEGMENT

def intersect(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersectS(s1, s2):
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2)

def getCrossPoint(s1, s2):
	base = s2.p2 - s2.p1
	a = s1.p1 - s2.p1
	b = s1.p2 - s2.p1
	d1 = abs(a.cross(base))
	d2 = abs(b.cross(base))
	t = d1 / (d1 + d2)
	return s1.p1 + (s1.p2 - s1.p1) * t

def getCrossPointC(c, l):
	pr = project(l, c.c)
	e = (l.p2 - l.p1) / (l.p2 - l.p1).abs()
	base = (c.r * c.r - (pr - c.c).norm()) ** 0.5
	return (pr - e * base, pr + e * base)

def printPoint(p1, p2):
	print(round(p1.x, 8), round(p1.y, 8), round(p2.x, 8), round(p2.y, 8))
nums = list(map(int, input().split()))
center = Point(nums[0], nums[1])
circle = Circle(center, nums[2])
n = int(input())
for i in range(n):
	nums = list(map(int, input().split()))
	l = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))
	(p1, p2) = getCrossPointC(circle, l)
	if p1.x < p2.x:
		printPoint(p1, p2)
	elif p1.x > p2.x:
		printPoint(p2, p1)
	elif p1.y < p2.y:
		printPoint(p1, p2)
	else:
		printPoint(p2, p1)


from typing import List, Tuple
from math import sqrt
from enum import IntEnum
EPS = 1e-10

def float_equal(x: float, y: float) -> bool:
	return abs(x - y) < EPS

class PointLocation(IntEnum):
	COUNTER_CLOCKWISE = 1
	CCW = 1
	CLOCKWISE = -1
	CW = -1
	ONLINE_BACK = 2
	O_B = 2
	ONLINE_FRONT = -2
	O_F = -2
	ON_SEGMENT = 0
	O_S = 0
PL = PointLocation

class Point:

	def __init__(self, x: float=0.0, y: float=0.0) -> None:
		self.x = x
		self.y = y

	def __repr__(self) -> str:
		return 'Point({}, {})'.format(self.x, self.y)

	def __eq__(self, other: object) -> bool:
		if not isinstance(other, Point):
			return NotImplemented
		return float_equal(self.x, other.x) and float_equal(self.y, other.y)

	def __add__(self, other: 'Point') -> 'Point':
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other: 'Point') -> 'Point':
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, k: float) -> 'Point':
		return Point(self.x * k, self.y * k)

	def __rmul__(self, k: float) -> 'Point':
		return self * k

	def __truediv__(self, k: float) -> 'Point':
		return Point(self.x / k, self.y / k)

	def __lt__(self, other: 'Point') -> bool:
		return self.y < other.y if abs(self.x - other.x) < EPS else self.x < other.x

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return sqrt(self.norm())

	def dot(self, other: 'Point') -> float:
		return self.x * other.x + self.y * other.y

	def cross(self, other: 'Point') -> float:
		return self.x * other.y - self.y * other.x

	def is_orthogonal(self, other: 'Point') -> bool:
		return float_equal(self.dot(other), 0.0)

	def is_parallel(self, other: 'Point') -> bool:
		return float_equal(self.cross(other), 0.0)

	def distance(self, other: 'Point') -> float:
		return (self - other).abs()

	def in_side_of(self, seg: 'Segment') -> bool:
		return seg.vector().dot(Segment(seg.p1, self).vector()) >= 0

	def in_width_of(self, seg: 'Segment') -> bool:
		return self.in_side_of(seg) and self.in_side_of(seg.reverse())

	def distance_to_line(self, seg: 'Segment') -> float:
		return abs((self - seg.p1).cross(seg.vector())) / seg.length()

	def distance_to_segment(self, seg: 'Segment') -> float:
		if not self.in_side_of(seg):
			return self.distance(seg.p1)
		if not self.in_side_of(seg.reverse()):
			return self.distance(seg.p2)
		else:
			return self.distance_to_line(seg)

	def location(self, seg: 'Segment') -> PointLocation:
		p = self - seg.p1
		d = seg.vector().cross(p)
		if d > EPS:
			return PointLocation.COUNTER_CLOCKWISE
		if d < -EPS:
			return PointLocation.CLOCKWISE
		if seg.vector().dot(p) < 0.0:
			return PointLocation.ONLINE_BACK
		if seg.vector().norm() < p.norm():
			return PointLocation.ONLINE_FRONT
		return PointLocation.ON_SEGMENT
Vector = Point

class Segment:

	def __init__(self, p1: Point=None, p2: Point=None) -> None:
		self.p1: Point = Point() if p1 is None else p1
		self.p2: Point = Point() if p2 is None else p2

	def __repr__(self) -> str:
		return 'Segment({}, {})'.format(self.p1, self.p2)

	def __eq__(self, other: object) -> bool:
		if not isinstance(other, Segment):
			return NotImplemented
		return self.p1 == other.p1 and self.p2 == other.p2

	def vector(self) -> Vector:
		return self.p2 - self.p1

	def reverse(self) -> 'Segment':
		return Segment(self.p2, self.p1)

	def length(self) -> float:
		return self.p1.distance(self.p2)

	def is_orthogonal(self, other: 'Segment') -> bool:
		return self.vector().is_orthogonal(other.vector())

	def is_parallel(self, other: 'Segment') -> bool:
		return self.vector().is_parallel(other.vector())

	def projection(self, p: Point) -> Point:
		v = self.vector()
		vp = p - self.p1
		return v.dot(vp) / v.norm() * v + self.p1

	def reflection(self, p: Point) -> Point:
		x = self.projection(p)
		return p + 2 * (x - p)

	def intersects(self, other: 'Segment') -> bool:
		d0: PointLocation = self.p1.location(other)
		d1: PointLocation = self.p2.location(other)
		d2: PointLocation = other.p1.location(self)
		d3: PointLocation = other.p2.location(self)
		return d0 * d1 * d2 * d3 == 0 or (d0 * d1 == -1 and d2 * d3 == -1)

	def intersection(self, other: 'Segment') -> Point:
		a = self.vector()
		b = other.vector()
		c = self.p1 - other.p1
		s = b.cross(c) / a.cross(b)
		return self.p1 + s * a

	def distance_with_segment(self, other: 'Segment') -> float:
		if not self.is_parallel(other) and self.intersects(other):
			return 0
		else:
			return min(self.p1.distance_to_segment(other), self.p2.distance_to_segment(other), other.p1.distance_to_segment(self), other.p2.distance_to_segment(self))
Line = Segment

class Circle:

	def __init__(self, c: Point=None, r: float=0.0) -> None:
		self.c: Point = Point() if c is None else c
		self.r: float = r

	def __eq__(self, other: object) -> bool:
		if not isinstance(other, Circle):
			return NotImplemented
		return self.c == other.c and self.r == other.r

	def __repr__(self) -> str:
		return 'Circle({}, {})'.format(self.c, self.r)

	def cross_point(self, line: Line) -> List[Point]:
		proj = line.projection(self.c)
		dist = self.c.distance_to_line(line)
		tan = sqrt(self.r * self.r - dist * dist)
		u = line.vector() / line.vector().abs()
		return sorted([proj - tan * u, proj + tan * u])

def main() -> None:
	(cx, cy, r) = [int(x) for x in input().split()]
	c = Circle(Point(cx, cy), r)
	q = int(input())
	for _ in range(q):
		(x0, y0, x1, y1) = [int(x) for x in input().split()]
		line = Line(Point(x0, y0), Point(x1, y1))
		(left, right) = c.cross_point(line)
		print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(left.x, left.y, right.x, right.y))
main()


import sys
from itertools import starmap
import math
readline = sys.stdin.readline
EPS = 1e-09
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2

class Circle(object):
	__slots__ = ('c', 'r')

	def __init__(self, c, r):
		self.c = c
		self.r = r

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se
Line = Segment

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r

def reflect(s, p):
	return p + (project(s, p) - p) * 2.0

def ccw(p1, p2, p3):
	a = p2 - p1
	b = p3 - p1
	if cross(a, b) > EPS:
		return 1
	if cross(a, b) < -EPS:
		return -1
	if dot(a, b) < -EPS:
		return 2
	if norm(a) < norm(b):
		return -2
	return 0

def intersect4(p1, p2, p3, p4):
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect2(s1, s2):
	return intersect4(s1.fi, s1.se, s2.fi, s2.se)

def getDistance(a, b):
	return abs(a - b)

def getDistanceLP(l, p):
	return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))

def getDistanceSP(s, p):
	if dot(s.se - s.fi, p - s.fi) < 0.0:
		return abs(p - s.fi)
	if dot(s.fi - s.se, p - s.se) < 0.0:
		return abs(p - s.se)
	return getDistanceLP(s, p)

def getDistances(s1, s2):
	if intersect2(s1, s2):
		return 0.0
	return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se), getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))

def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t

def getCrossPoints(c, l):
	pr = project(l, c.c)
	e = (l.se - l.fi) / abs(l.se - l.fi)
	base = math.sqrt(c.r * c.r - norm(pr - c.c))
	return Segment(pr + e * base, pr - e * base)
(x, y, r) = map(int, readline().split())
ci = Circle(complex(x, y), r)
n = int(readline())
for _ in [0] * n:
	(p0, p1) = starmap(complex, zip(*[map(int, readline().split())] * 2))
	ppp = getCrossPoints(ci, Line(p0, p1))
	if ppp.se.real < ppp.fi.real or (ppp.se.real == ppp.fi.real and ppp.se.imag < ppp.fi.imag):
		(ppp.fi, ppp.se) = (ppp.se, ppp.fi)
	print('{:.10f} {:.10f} {:.10f} {:.10f}'.format(ppp.fi.real, ppp.fi.imag, ppp.se.real, ppp.se.imag))


import math

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def projection(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	pro = a * dot(a, b) / abs(a) ** 2
	t = p0 + pro
	return t

def get_cross_point(p0, p1, p2):
	pro = projection(p0, p1, p2)
	e = (p1 - p0) / abs(p1 - p0)
	base = (r ** 2 - abs(pro - p2) ** 2) ** 0.5
	if (pro - e * base).real == (pro + e * base).real:
		if (pro - e * base).imag < (pro + e * base).imag:
			ans1 = pro - e * base
			ans2 = pro + e * base
		else:
			ans1 = pro + e * base
			ans2 = pro - e * base
	elif (pro - e * base).real < (pro + e * base).real:
		ans1 = pro - e * base
		ans2 = pro + e * base
	else:
		ans1 = pro + e * base
		ans2 = pro - e * base
	return (ans1.real, ans1.imag, ans2.real, ans2.imag)
(cx, cy, r) = map(int, input().split())
p2 = complex(cx, cy)
q = int(input())
for _ in range(q):
	(x0, y0, x1, y1) = map(int, input().split())
	p0 = complex(x0, y0)
	p1 = complex(x1, y1)
	print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(*get_cross_point(p0, p1, p2)))


from math import sqrt

def cross_point(circle, p1, p2):
	(x0, y0, r) = circle
	(x1, y1) = p1
	(x2, y2) = p2
	p1p2 = norm((x2 - x1, y2 - y1))
	op1 = norm((x0 - x1, y0 - y1))
	rr = r * r
	dp = dot((x0 - x1, y0 - y1), (x2 - x1, y2 - y1))
	d = dp * dp - p1p2 * (op1 - rr)
	if abs(d) < 1e-10:
		t = dp / p1p2
		return [(x1 + t * (x2 - x1), y1 + t * (y2 - y1))]
	elif d > 1e-10:
		t1 = (dp + sqrt(d)) / p1p2
		t2 = (dp - sqrt(d)) / p1p2
		return [(x1 + t1 * (x2 - x1), y1 + t1 * (y2 - y1)), (x1 + t2 * (x2 - x1), y1 + t2 * (y2 - y1))]
	else:
		return None

def norm(v):
	(x, y) = v
	return x ** 2 + y ** 2

def dot(v1, v2):
	(x1, y1) = v1
	(x2, y2) = v2
	return x1 * x2 + y1 * y2

def run():
	c = [int(i) for i in input().split()]
	q = int(input())
	for _ in range(q):
		(x1, y1, x2, y2) = [int(i) for i in input().split()]
		ps = cross_point(c, (x1, y1), (x2, y2))
		if ps is None:
			raise ValueError('the circle and line do not intersect')
		if len(ps) == 1:
			ps *= 2
		(p1, p2) = ps
		if p1 > p2:
			(p1, p2) = (p2, p1)
		print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(*p1, *p2))
run()


from math import sqrt
(cx, cy, r) = map(int, input().split())
c = [cx, cy]
q = int(input())

class Line:
	pass

def dot(a, b):
	return sum([i * j for (i, j) in zip(a, b)])

def add(a, b):
	return [a[0] + b[0], a[1] + b[1]]

def sub(a, b):
	return [a[0] - b[0], a[1] - b[1]]

def multi(k, a):
	return [k * a[0], k * a[1]]

def cross(a, b):
	return a[0] * b[1] - a[1] * b[0]

def norm(a):
	return sqrt(a[0] ** 2 + a[1] ** 2)

def proj(p, l):
	base = sub(l.p2, l.p1)
	hypo = sub(p, l.p1)
	t = dot(hypo, base) / norm(base)
	return add(l.p1, multi(t / norm(base), base))
for i in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	l = Line()
	l.p1 = [x1, y1]
	l.p2 = [x2, y2]
	pr = proj(c, l)
	e = multi(1 / norm(sub(l.p2, l.p1)), sub(l.p2, l.p1))
	e2 = multi(-1, e)
	base = sqrt(r ** 2 - norm(sub(pr, c)) ** 2)
	a = add(pr, multi(base, e))
	b = add(pr, multi(base, e2))
	ans = [a, b]
	ans = sorted(ans, key=lambda x: (x[0], x[1]))
	print(' '.join([str(round(i, 8)) for o in ans for i in o]))


import math
EPS = 10 ** (-9)

def is_equal(a, b):
	return abs(a - b) < EPS

def norm(v, i=2):
	ret = 0
	n = len(v)
	for j in range(n):
		ret += abs(v[j]) ** i
	return math.pow(ret, 1 / i)

class Vector(list):

	def __add__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) + other.__getitem__(i)
		return self.__class__(ret)

	def __radd__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = other.__getitem__(i) + super().__getitem__(i)
		return self.__class__(ret)

	def __iadd__(self, other):
		n = len(self)
		for i in range(n):
			self[i] += other.__getitem__(i)
		return self

	def __sub__(self, others):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) - others.__getitem__(i)
		return self.__class__(ret)

	def __isub__(self, other):
		n = len(self)
		for i in range(n):
			self[i] -= other.__getitem__(i)
		return self

	def __rsub__(self, others):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = others.__getitem__(i) - super().__getitem__(i)
		return self.__class__(ret)

	def __mul__(self, other):
		n = len(self)
		if isinstance(other, list):
			ret = 0
			for i in range(n):
				ret += super().__getitem__(i) * other.__getitem__(i)
			return ret
		else:
			ret = [0] * n
			for i in range(n):
				ret[i] = super().__getitem__(i) * other
			return self.__class__(ret)

	def __rmul__(self, other):
		n = len(self)
		if isinstance(other, list):
			ret = 0
			for i in range(n):
				ret += super().__getitem__(i) * other.__getitem__(i)
			return ret
		else:
			ret = [0] * n
			for i in range(n):
				ret[i] = super().__getitem__(i) * other
			return self.__class__(ret)

	def __truediv__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) / other
		return self.__class__(ret)

	def norm(self, i):
		return norm(self, i)

	def __pow__(self, other):
		n = len(self)
		ret = [0] * 3
		x = self[:]
		y = other[:]
		if n == 2:
			x.append(0)
			y.append(0)
		if n == 2 or n == 3:
			for i in range(3):
				(ret[0], ret[1], ret[2]) = (x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0])
			ret = Vector(ret)
			if n == 2:
				return ret
			else:
				return ret

class Segment:

	def __init__(self, v1, v2):
		self.v1 = v1
		self.v2 = v2

	def length(self):
		return norm(self.v1 - self.v2)

	def get_unit_vec(self):
		dist = norm(self.v2 - self.v1)
		if dist != 0:
			return (self.v2 - self.v1) / dist
		else:
			return False

	def projection(self, vector):
		unit_vec = self.get_unit_vec()
		t = unit_vec * (vector - self.v1)
		return self.v1 + t * unit_vec

	def is_vertical(self, other):
		return is_equal(0, self.get_unit_vec() * other.get_unit_vec())

	def is_horizontal(self, other):
		return is_equal(0, self.get_unit_vec() ** other.get_unit_vec())

	def reflection(self, vector):
		projection = self.projection(vector)
		v = projection - vector
		return projection + vector

	def include(self, vector):
		proj = self.projection(vector)
		if not is_equal(norm(proj - vector), 0):
			return False
		else:
			n = len(self.v1)
			f = True
			for i in range(n):
				f &= self.v1[i] <= vector[i] <= self.v2[i] or self.v2[i] <= vector[i] <= self.v1[i]
			return f

	def distance(self, other):
		if isinstance(other, Vector):
			proj = self.projection(other)
			if self.include(proj):
				return norm(proj - other)
			else:
				ret = []
				ret.append(norm(self.v1 - other))
				ret.append(norm(self.v2 - other))
				return min(ret)

	def ccw(self, vector):
		direction = self.v2 - self.v1
		v = vector - self.v1
		if self.include(vector):
			return 0
		else:
			cross = direction ** v
			if cross[2] <= 0:
				return 1
			else:
				return -1

	def intersect(self, segment):
		ccw12 = self.ccw(segment.v1)
		ccw13 = self.ccw(segment.v2)
		ccw20 = segment.ccw(self.v1)
		ccw21 = segment.ccw(self.v2)
		if ccw12 * ccw13 * ccw20 * ccw21 == 0:
			return True
		elif ccw12 * ccw13 < 0 and ccw20 * ccw21 < 0:
			return True
		else:
			return False

	def intersect_point(self, segment):
		d1 = norm(self.projection(segment.v1) - segment.v1)
		d2 = norm(self.projection(segment.v2) - segment.v2)
		return segment.v1 + d1 / (d1 + d2) * (segment.v2 - segment.v1)

class Line(Segment):

	def include(self, vector):
		proj = self.projection(vector)
		return is_equal(norm(proj - vector), 0)

	def distance(self, vector):
		return norm(self.projection(vector) - vector)

class Circle:

	def __init__(self, vector, r):
		self.c = vector
		self.r = r

	def intersect_point(self, other):
		if isinstance(other, Line):
			if other.distance(self.c) > self.r:
				return False
			else:
				d = other.distance(self.c)
				proj = other.projection(self.c)
				unit_v = other.get_unit_vec()
				t = (self.r ** 2 - d ** 2) ** 0.5
				return (proj + t * unit_v, proj - t * unit_v)
(cx, cy, r) = map(int, input().split())
circle = Circle(Vector([cx, cy]), r)
q = int(input())
lines = [0] * q
for i in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	lines[i] = Line(Vector([x1, y1]), Vector([x2, y2]))
for i in range(q):
	(ic1, ic2) = circle.intersect_point(lines[i])
	ics = [ic1, ic2]
	ics.sort()
	print('{:.7f} {:.7f} {:.7f} {:.7f}'.format(*ics[0], *ics[1]))


from math import sqrt

def intersection_cl(S0, S1, C0, r):
	(x0, y0) = S0
	(x1, y1) = S1
	(cx, cy) = C0
	xd = x1 - x0
	yd = y1 - y0
	X = x0 - cx
	Y = y0 - cy
	A = xd ** 2 + yd ** 2
	B = xd * X + yd * Y
	C = X ** 2 + Y ** 2 - r ** 2
	if B ** 2 < A * C:
		return tuple()
	D = B ** 2 - A * C
	s1 = (-B + sqrt(D)) / A
	s2 = (-B - sqrt(D)) / A
	return ((x0 + xd * s1, y0 + yd * s1), (x0 + xd * s2, y0 + yd * s2))
(cx, cy, r) = map(int, input().split())
q = int(input())
for i in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	(p0, p1) = sorted(intersection_cl((x1, y1), (x2, y2), (cx, cy), r))
	print('%.08f %.08f %.08f %.08f' % (p0 + p1))


import sys
from math import sqrt
from sys import stdin
input = stdin.readline

class Point(object):
	epsilon = 1e-10

	def __init__(self, x=0.0, y=0.0):
		if isinstance(x, tuple):
			self.x = x[0]
			self.y = x[1]
		else:
			self.x = x
			self.y = y

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Point(other * self.x, other * self.y)

	def __truediv__(self, other):
		return Point(self.x / other, self.y / other)

	def __lt__(self, other):
		if self.x == other.x:
			return self.y < other.y
		else:
			return self.x < other.x

	def __eq__(self, other):
		from math import fabs
		if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
			return True
		else:
			return False

	def norm(self):
		return self.x * self.x + self.y * self.y

	def __abs__(self):
		return sqrt(self.norm())

	def ccw(self, p0, p1):
		a = Vector(p1 - p0)
		b = Vector(self - p0)
		if Vector.cross(a, b) > Point.epsilon:
			return 1
		elif Vector.cross(a, b) < -Point.epsilon:
			return -1
		elif Vector.dot(a, b) < -Point.epsilon:
			return 2
		elif a.norm() < b.norm():
			return -2
		else:
			return 0

	def project(self, s):
		base = Vector(s.p2 - s.p1)
		a = Vector(self - s.p1)
		r = Vector.dot(a, base)
		r /= base.norm()
		return s.p1 + base * r

	def reflect(self, s):
		proj = self.project(s)
		return self + (proj - self) * 2

	def distance(self, s):
		if Vector.dot(s.p2 - s.p1, self - s.p1) < 0.0:
			return abs(self - s.p1)
		if Vector.dot(s.p1 - s.p2, self - s.p2) < 0.0:
			return abs(self - s.p2)
		return abs(Vector.cross(s.p2 - s.p1, self - s.p1) / abs(s.p2 - s.p1))

class Vector(Point):

	def __init__(self, x=0.0, y=0.0):
		if isinstance(x, tuple):
			self.x = x[0]
			self.y = x[1]
		elif isinstance(x, Point):
			self.x = x.x
			self.y = x.y
		else:
			self.x = x
			self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Vector(other * self.x, other * self.y)

	def __truediv__(self, other):
		return Vector(other / self.x, other / self.y)

	@classmethod
	def dot(cls, a, b):
		return a.x * b.x + a.y * b.y

	@classmethod
	def cross(cls, a, b):
		return a.x * b.y - a.y * b.x

	@classmethod
	def is_orthogonal(cls, a, b):
		return Vector.dot(a, b) == 0.0

	@classmethod
	def is_parallel(cls, a, b):
		return Vector.cross(a, b) == 0.0

class Segment(object):

	def __init__(self, p1=Point(), p2=Point()):
		if isinstance(p1, Point):
			self.p1 = p1
			self.p2 = p2
		elif isinstance(p1, tuple):
			self.p1 = Point(p1[0], p1[1])
			self.p2 = Point(p2[0], p2[1])

	def intersect(self, s):
		ans1 = s.p1.ccw(self.p1, self.p2) * s.p2.ccw(self.p1, self.p2)
		ans2 = self.p1.ccw(s.p1, s.p2) * self.p2.ccw(s.p1, s.p2)
		return ans1 <= 0 and ans2 <= 0

	def cross_point(self, s):
		base = s.p2 - s.p1
		d1 = abs(Vector.cross(base, self.p1 - s.p1))
		d2 = abs(Vector.cross(base, self.p2 - s.p1))
		t = d1 / (d1 + d2)
		return self.p1 + (self.p2 - self.p1) * t

	def distance(self, s):
		if self.intersect(s):
			return 0.0
		d1 = s.p1.distance(self)
		d2 = s.p2.distance(self)
		d3 = self.p1.distance(s)
		d4 = self.p2.distance(s)
		return min(d1, d2, d3, d4)

	@classmethod
	def is_orthogonal(cls, s1, s2):
		a = Vector(s1.p2 - s1.p1)
		b = Vector(s2.p2 - s2.p1)
		return Vector.is_orthogonal(a, b)

	@classmethod
	def is_parallel(cls, s1, s2):
		a = Vector(s1.p2 - s1.p1)
		b = Vector(s2.p2 - s2.p1)
		return Vector.is_parallel(a, b)

class Line(Segment):
	pass

class Cirle(object):

	def __init__(self, x, y=Point(), r=1.0):
		if isinstance(x, Point):
			self.c = x
			self.r = y
		elif isinstance(x, tuple):
			self.c = Point(x[0], x[1])
			self.r = r

	def cross_point(self, s):
		pr = self.c.project(s)
		e = (s.p2 - s.p1) / abs(s.p2 - s.p1)
		base = sqrt(self.r * self.r - (pr - self.c).norm())
		return (pr + e * base, pr - e * base)

def main(args):
	(x, y, r) = map(int, input().split())
	q = int(input())
	c = Cirle(Point(x, y), r)
	for _ in range(q):
		(x1, y1, x2, y2) = map(int, input().split())
		p1 = Point(x1, y1)
		p2 = Point(x2, y2)
		s = Segment(p1, p2)
		(ans1, ans2) = c.cross_point(s)
		if ans1.x < ans2.x:
			print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(ans1.x, ans1.y, ans2.x, ans2.y))
		elif ans1.x == ans2.x and ans1.y <= ans2.y:
			print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(ans1.x, ans1.y, ans2.x, ans2.y))
		else:
			print('{:.8f} {:.8f} {:.8f} {:.8f}'.format(ans2.x, ans2.y, ans1.x, ans1.y))
main(sys.argv[1:])