#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,M,R;
double cx[2000],cy[2000],cz[2000],cr[2000],x[15],y[15],z[15],X,Y,Z,b[15];
int inter[2000];
int main(){
	while(true){
		cin>>N>>M>>R;
		if(N==0) break;
		rep(i,N) inter[i]=0;
		rep(i,N) cin>>cx[i]>>cy[i]>>cz[i]>>cr[i];
		rep(i,M) cin>>x[i]>>y[i]>>z[i]>>b[i];
		cin>>X>>Y>>Z;
		rep(j,M) b[j]/=( (X-x[j])*(X-x[j])+(Y-y[j])*(Y-y[j])+(Z-z[j])*(Z-z[j]) );
//		rep(j,M) show(b[j]);
		double ans=0;
		rep(i,N) rep(j,M){
			double A=(X-x[j])*(X-x[j])+(Y-y[j])*(Y-y[j])+(Z-z[j])*(Z-z[j]);
			double B=-2* ((X-x[j])*(X-cx[i])+(Y-y[j])*(Y-cy[i])+(Z-z[j])*(Z-cz[i]));
			double C=(X-cx[i])*(X-cx[i])+(Y-cy[i])*(Y-cy[i])+(Z-cz[i])*(Z-cz[i])-cr[i]*cr[i];
			double D=B*B-4*A*C;
			if(D<0) continue;
			for(int s=-1;s<=1;s+=2){
				double xx=(-B+s*sqrt(D))/(2.0*A);
				if(0<xx&&xx<1) inter[i]|=(1<<j);
			}
		}
//		rep(i,N) show(inter[i]);
		rep(i,1<<M){
			int a=0;
			rep(j,N) if(inter[j]&i) a++;
			if(a<=R){
				double tmp=0;
				rep(j,M) if((i>>j)&1) tmp+=b[j];
				chmax(ans,tmp);
			}
		}
		printf("%.12f\n",ans);
	}
}