#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;

#define ESP 1e-7

struct v3d{
	double x, y, z;

	double dot(const v3d &v) const{
		return x * v.x + y * v.y + z * v.z;
	}

	v3d sub(const v3d &v) const{
		return (v3d){x - v.x, y - v.y, z - v.z};
	}
};

typedef const v3d &cv3d;

bool intersect(cv3d s, double r, cv3d p, cv3d q){
	v3d v = q.sub(p), w = p.sub(s);
	double a = v.dot(v);
	double b = v.dot(w);
	double c = w.dot(w) - r * r;
	double D = b * b - a * c;
	if(abs(D) >= 0.0){
		D = sqrt(D);
		double t = (-b + D) / a;
		if(t >= 0.0 && t <= 1.0){ return true; }
		t = (-b - D) / a;
		if(t >= 0.0 && t <= 1.0){ return true; }
	}
	return false;
}

int main(){
	int n, m, rem;

	while(scanf("%d%d%d", &n, &m, &rem), n){
		vector<v3d> Sp(n), Tp(m);
		vector<double> Sr(n), Tb(m);
		v3d E;

		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf%lf", &Sp[i].x, &Sp[i].y, &Sp[i].z, &Sr[i]);
		}
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf%lf%lf", &Tp[i].x, &Tp[i].y, &Tp[i].z, &Tb[i]);
		}
		scanf("%lf%lf%lf", &E.x, &E.y, &E.z);

		vector<double> light(m);
		vector<bitset<2000> > intr(m);
		for(int i = 0; i < m; ++i){
			v3d dif = Tp[i].sub(E);
			light[i] = Tb[i] / dif.dot(dif);

			for(int j = 0; j < n; ++j){
				if(intersect(Sp[j], Sr[j], Tp[i], E)){
					intr[i].set(j);
				}
			}
		}

		double ans = 0.0;
		for(int i = (1 << m) - 1; i > 0; --i){
			bitset<2000> bs;
			double sum = 0.0;
			for(int j = 0; j < m; ++j){
				if(i >> j & 1){
					bs |= intr[j];
					sum += light[j];
				}
			}
			
			if(bs.count() <= rem && ans < sum){
				ans = sum;
			}
		}

		printf("%f\n", ans);

	}
}