require 'matrix'

cx, cy, r = gets.split.map &:to_i
c = Vector[ cx, cy ]
q = gets.to_i
q.times do
  x1, y1, x2, y2 = gets.split.map &:to_i
  p0 = Vector[ x1, y1 ]
  p1 = Vector[ x2, y2 ]
  p0pr_norm = (c - p0).inner_product(p1 - p0).abs / (p1 - p0).norm
  p0p1_base = (p1 - p0) / (p1 - p0).norm
  pr = p0 + p0p1_base * p0pr_norm
  x = ( r**2 - (c - pr).norm**2 ) ** (1/2.0)
  i1 = pr - p0p1_base * x
  i2 = pr + p0p1_base * x
  puts "%.7f %.7f %.7f %.7f" % [ i1[0], i1[1], i2[0], i2[1] ]
end