#include <algorithm>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
#include <iostream>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P projection(P a, P b){
  return dot(a,b)/norm(b)*b;
}

double p_to_l_dist(P p, L l){
  return abs(cross(l.second-l.first,p-l.first))/abs(l.first-l.second);
}

vector<P> sort_comp(vector<P> a){
  int l = a.size();
  vector< pair<double, double> > t(l);
  for(int i = 0; i < l; ++i){
    t[i].first = a[i].X;
    t[i].second = a[i].Y;
  }
  sort(t.begin(),t.end());
  for(int i = 0; i < l; ++i){
    a[i] = P(t[i].first,t[i].second);
  }
  return a;
}

vector<P> cpcl(C c, L l){
  double d = p_to_l_dist(c.first,l), r = c.second;
  P m = l.first + projection(c.first-l.first,l.second-l.first);
  P x = sqrt(r*r-d*d)/abs(l.second-l.first)*(l.second-l.first);
  vector<P> cp(2,m);
  cp[0] -= x;
  cp[1] += x;
  return cp;
}

int main(){
  double x1, y1, x2, y2, r;
  cin >> x1 >> y1 >> r;
  C c = C(P(x1,y1),r);
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    cin >> x1 >> y1 >> x2 >> y2;
    L l;
    l.first = P(x1,y1);
    l.second = P(x2,y2);
    vector<P> cp = sort_comp(cpcl(c,l));
    printf("%.10lf %.10lf %.10lf %.10lf\n", cp[0].X, cp[0].Y, cp[1].X, cp[1].Y);
  }
  return 0;
}