/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let eps = 1e-8;

int sign(let x) { return (x < -eps) ? -1 : (x > eps ? 1 : 0); }

struct Point {
  let x, y;
  friend bool operator < (Point a, Point b) {
    if (sign(a.x - b.x) == 0) return sign(a.y - b.y) < 0; 
    return sign(a.x - b.x) < 0;
  }
  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
  Point operator ~ () {
    return (Point) {x, -y};
  }

  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }

  let dist() {
    return sqrt(x * x + y * y);
  }

  Point Rotate(Point k) {
    let z = k.dist();
    return Rotate(k.y / z, k.x / z);
  }

  void EchoWith(char c) {
    printf("%.8Lf %.8Lf", x, y);
    putchar(c);
  }
};

typedef Point Vec;

struct Line {
  Point p;
  Vec v;

  Line(Point a, Point b) {
    p = a, v = b - a;
  }
  
  Line operator - (Vec k) {
    return (Line) {p - k, v};
  }

  Line Rotate(let sink, let cosk) {
    return (Line) {
      p.Rotate(sink, cosk), v.Rotate(sink, cosk)
    };
  }

  Line Rotate(Vec v) {
    let z = v.dist();
    return Rotate(v.y / z, v.x / z);
  }

};

struct Circle {
  Point o;
  let r;
  friend pair<Point, Point> Cross(Circle c, Line l) {
    Point a = (l.p - c.o).Rotate(~l.v);
    if (sign(a.y - c.r) > 0 || sign(a.y + c.r) < 0) {
    }
      
    if (sign(a.y - c.r) == 0) {
      Point res = ((Point) {0, c.r}).Rotate(l.v) + c.o;
      return make_pair(res, res);
    }

    if (sign(a.y + c.r) == 0) {
      Point res = ((Point) {0, -c.r}).Rotate(l.v) + c.o;
      return make_pair(res, res);
    }

    let y = a.y, xp = sqrt(c.r * c.r - y * y);
    Point lc = (Point) {-xp, y}.Rotate(l.v) + c.o, 
          rc = (Point) {xp, y}.Rotate(l.v) + c.o;
    return make_pair(lc, rc);
  }
};

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Line ReadLine() {
  Point a = ReadPoint(), b = ReadPoint();
  return (Line) {a, b};
}

Circle ReadCircle() {
  Point p = ReadPoint();
  let c;
  scanf("%Lf", &c);
  return (Circle) {p, c};
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_7_D.in", "r", stdin);
//   freopen("CGL_7_D.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_7_D.log", "w", stderr);
// #endif
  Circle c = ReadCircle();
  int q = read();
  while (q--) {
    Line l = ReadLine();
    pair<Point, Point> res = Cross(c, l);
    if (res.second < res.first) 
      swap(res.first, res.second);
    res.first.EchoWith(' ');
    res.second.EchoWith('\n');
  }
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_7_D CGL_7_D.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_7_D CGL_7_D.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_7_D < CGL_7_D.in > CGL_7_D.out
==================
}}} */



Measured memory_bytes: 3244