#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
static const double EPS = pow(10,-10);
typedef long long ll;
static int COUNTER_CLOCKWISE = 1;
static int CLOCKWISE = -1;
static int ONLINE_BACK = 2;
static int ONLINE_FRONT = -2;
static int ON_SEGMENT = 0;

class Vector2{
  public:
  double x, y;
  Vector2(){}
  Vector2(double x, double y): x(x), y(y) {}

  Vector2 operator + (Vector2 v) {
    return Vector2(x + v.x , y + v.y);
  }
  Vector2 operator - (Vector2 v) {
    return Vector2(x - v.x , y - v.y);
  }

  Vector2 operator * (double d){
    return Vector2(d*x, d*y);
  }

  double norm(){
    return pow(x,2) + pow(y,2);
  }

  double abs(){
    return sqrt(norm());
  }

};

class Circle{
  public:
  Vector2 center;
  double r;
  Circle(){};
  Circle(Vector2 center_, double r):center(center),r(r){};
};

double dot(Vector2 a, Vector2 b){
  return a.x * b.x + a.y * b.y; 
}

double cross(Vector2 a, Vector2 b){
  return a.x * b.y - a.y*b.x;
}

Vector2 projection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 base = b - a;
  Vector2 hypo = p - a;
  double norm_base = pow(base.x,2) + pow(base.y,2);

  Vector2 x;
  x = a + base*(dot(hypo,base) / norm_base);
  return x;
}

Vector2 refrection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 v, p_projection;
  p_projection = projection(a,b,p); 
  v = p_projection + (p_projection - p);
  return v;
}

int ccw(Vector2 a, Vector2 b, Vector2 p){
  Vector2 hypo = p - a;
  Vector2 base = b - a;
  if(cross(base,hypo) > EPS) return COUNTER_CLOCKWISE;
  if(cross(base,hypo) < -EPS) return CLOCKWISE;
  if(dot(base,hypo) < -EPS) return ONLINE_BACK;
  if(hypo.norm() > base.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Vector2 a,Vector2 b,Vector2 p,Vector2 q){
  int t1, t2;
  t1 =ccw(a,b,p)*ccw(a,b,q);
  t2 =ccw(p,q,a)*ccw(p,q,b);
  if(t1 <= 0 && t2 <= 0) return true;
  else return false;
}

Vector2 crossPoint(Vector2 a,Vector2 b,Vector2 p,Vector2 q){
  Vector2 base, hypo_1, hypo_2, v;
  base = b-a;
  hypo_1 = p-a;
  hypo_2 = q-a;
  double d1 = abs(cross(base, hypo_1)); 
  double d2 = abs(cross(base, hypo_2));
  double ratio = d1/(d1+d2);
  v = p + (hypo_2 - hypo_1)*ratio;
  return v;
}

double distance(Vector2 a,Vector2 b,Vector2 p){
  if(dot(b-a, p-b) > 0) return (p-b).abs();
  if(dot(b-a, p-a) < 0) return (p-a).abs();
  return (p - projection(a,b,p)).abs();
}

double distance(Vector2 a,Vector2 b,Vector2 p,Vector2 q){
  if(intersect(a,b,p,q)) return 0;
  vector<double> d_arr(4) ;
  d_arr[0] = distance(a,b,p);
  d_arr[1] = distance(a,b,q);
  d_arr[2] = distance(p,q,a);
  d_arr[3] = distance(p,q,b);
  return min(min(d_arr[0],d_arr[1]),
             min(d_arr[2],d_arr[3]));
}

pair<Vector2,Vector2> crossPoint(Circle circle, Vector2 a, Vector2 b){
  Vector2 base = b-a ;
  Vector2 pro = projection(a,b,circle.center);
  double ratio = sqrt(pow(circle.r,2) -(pro-circle.center).norm())
                 / base.abs();
  Vector2 v_1, v_2, tmp;
  v_1 = pro - base*ratio;
  v_2 = pro + base*ratio;
  if((v_1.x == v_2.x && v_1.y > v_2.y) || v_1.x > v_2.x) swap(v_1,v_2);
  return make_pair(v_1,v_2);
}       




int main(){
  Vector2 a,b;
  pair<Vector2,Vector2> ans;
  Circle c;
  cin >> c.center.x >> c.center.y >> c.r;
  int queri;
  cin >> queri;
  rep(i,queri){
    cin >> a.x >> a.y >> b.x >> b.y;
    ans = crossPoint(c, a, b);
    cout << fixed << setprecision(8);
    cout << ans.first.x << " " << ans.first.y << " ";
    cout << ans.second.x << " " << ans.second.y;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3288