#include <bits/stdc++.h>
using namespace std;
double EPS = 0.00000001;
int sign(double x){
	if (x > EPS){
		return 1;
	} else if (x < -EPS){
		return -1;
	} else {
		return 0;
	}
}
bool equals(double x, double y){
	return abs(x - y) < EPS;
}
struct point{
	double x;
	double y;
	point(){
		x = 0;
		y = 0;
	}
	point(double X, double Y){
		x = X;
		y = Y;
	}
	point operator +(){
		return point(x, y);
	}
	point operator -(){
		return point(-x, -y);
	}
	point operator +(point P){
		return point(x + P.x, y + P.y);
	}
	point operator -(point P){
		return point(x - P.x, y - P.y);
	}
	point& operator +=(point P){
		x += P.x;
		y += P.y;
		return *this;
	}
	point& operator -=(point P){
		x -= P.x;
		y -= P.y;
		return *this;
	}
	point operator *(double k){
		return point(x * k, y * k);
	}
	point operator /(double k){
		return point(x / k, y / k);
	}
	point& operator *=(double k){
		x *= k;
		y *= k;
		return *this;
	}
	point& operator /=(double k){
		x /= k;
		y /= k;
		return *this;
	}
	bool operator <(point P){
		return sign(P.x - x) == 1 || equals(x, P.x) && sign(P.y - y) == 1;
	}
	bool operator >(point P){
		return (P < *this);
	}
};
istream& operator >>(istream &is, point &p){
	double x, y;
	is >> x >> y;
	p = point(x, y);
	return is;
}
ostream& operator <<(ostream &os, point p){
	os << p.x << ' ' << p.y;
	return os;
}
double norm(point P){
	return P.x * P.x + P.y * P.y;
}
double abs(point P){
	return sqrt(norm(P)); 
}
double dot(point P, point Q){
	return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
  return P.x * Q.y - P.y * Q.x;
}
struct line{
	point A;
	point B;
	line(){
	}
	line(point P){
	  B = P;
	}
	line(point P, point Q){
		A = P;
		B = Q;
	}
};
istream& operator >>(istream &is, line &L){
	point A, B;
	is >> A >> B;
	L = line(A, B);
	return is;
}
point vec(line L){
	return L.B - L.A;
}
point unit(line L){
	return vec(L) / abs(vec(L));
}
point projection(point P, line L){
	return L.A + vec(L) * dot(P - L.A, vec(L)) / norm(vec(L));
}
double point_line_distance(point P, line L){
	return abs(cross(P - L.A, vec(L))) / abs(vec(L));
}
struct circle{
  point c;
  double r;
  circle(){
  }
	circle(point C, double R){
		c = C;
		r = R;
	}
};
istream& operator >>(istream &is, circle &C){
    point P;
    double r;
    cin >> P >> r;
    C = circle(P, r);
    return is;
}
int line_circle_intersection_count(line L, circle C){
	return sign(C.r - point_line_distance(C.c, L)) + 1;
}
vector<point> line_circle_intersection(line L, circle C){
	int count = line_circle_intersection_count(L, C);
	vector<point> ans;
	if (count == 0){
		return ans;
	} else if (count == 1) {
		ans.push_back(projection(C.c, L));
		return ans;
	} else {
		point P = projection(C.c, L);
		double d = sqrt(pow(C.r, 2) - pow(point_line_distance(C.c, L), 2));
		ans.push_back(P + unit(L) * d);
		ans.push_back(P - unit(L) * d);
		return ans;
	}
}
int main(){
  cout << fixed << setprecision(15);
  circle C;
  cin >> C;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    line L;
    cin >> L;
    vector<point> ans = line_circle_intersection(L, C);
    sort(ans.begin(), ans.end());
    if (ans.size() == 1){
      cout << ans[0] << ' ' << ans[0] << endl;
    } else {
      cout << ans[0] << ' ' << ans[1] << endl;
    }
  }
}


Measured memory_bytes: 3292