#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


double eps = 1e-7;
struct Point {
    double x,y,z;
};

Point operator+(Point p,Point q){
    return Point{p.x+q.x, p.y+q.y, p.z+q.z};
}

Point operator-(Point p,Point q){
    return Point{p.x-q.x, p.y-q.y, p.z-q.z};
}

Point operator*(double k, Point p){
    return Point{k*p.x, k*p.y, k*p.z};
}

double dot(Point p,Point q){
    return p.x*q.x + p.y*q.y + p.z*q.z;
}

Point proj(Point x, Point s,Point t){
    x=x-s; t=t-s;
    double k = dot(x,t)/dot(t,t);
    return s + k * t;
}

Point cont(Point x, Point s, Point t){
    Point m=proj(x,s,t);
    return 2*m-x;
}

double cross(Point s, Point t, Point c,double r){
    Point h = proj(c,s,t);
    double d = dot(c-h,c-h);
    if(d>r*r)return -1;
    return dot(t-s,h-s)/dot(t-s,t-s)-sqrt((r*r-d)/dot(t-s,t-s));
}

void solve(int n){
    Point s ={0,0,0};
    Point t;
    cin>>t.x>>t.y>>t.z;
    Point a[n];
    double r[n];
    rep(i,n)cin>>a[i].x>>a[i].y>>a[i].z>>r[i];
    rep(_,10){
        int idx=-1;
        double mi=inf;
        rep(i,n){
            double res = cross(s,t,a[i],r[i]);
            if(res>eps&&res<mi){
                mi=res;
                idx=i;
            }
        }
        if(idx==-1){
            cout<<s.x<<" "<<s.y<<" "<<s.z<<endl;
            return;
        }
        Point ns = s + mi*(t-s);
        t = cont(s,a[idx],ns);
        s = ns;
    }
}
int main(){
    int n;
    cout<<fixed<<setprecision(12);
    while(cin>>n,n!=0)solve(n);
    return 0;
}
