#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef long double D;
typedef vector<D> P;
const D EPS = 1e-8;

int n,m,r;
P s[2010], t[20], e;
D sr[2010], b[20];

inline D dis2(P a, P b){
  D res = 0;
  rep(i,3)res += (a[i]-b[i])*(a[i]-b[i]);
  return res;
}

inline P mul(D k, P a){
  rep(i,a.size())a[i] *= k;
  return a;
}

inline P add(P a, P b){
  rep(i,a.size())a[i] += b[i];
  return a;
}

vector<int> check(int x){
  vector<int> res;

  rep(i,n){
    bool f1 = dis2(e, s[i])+EPS<sr[i]*sr[i];
    bool f2 = dis2(t[x], s[i])+EPS<sr[i]*sr[i];
    if(f1!=f2){
      res.push_back(i);
    }else if(!f1 && !f2){
      P left = e, right = t[x];
      rep(hoge,30){
	P m1 = mul(1.0/3,add(mul(2.0,left),right));
	P m2 = mul(1.0/3,add(left,mul(2.0,right)));
	
	D d1 = dis2(s[i],m1), d2 = dis2(s[i],m2);
	if(d1 < d2)right = m2;
	else left = m1;
      }
      //cout << i << " " << dis2(left,s[i]) << endl;
      if(dis2(left, s[i]) +EPS < sr[i]*sr[i])res.push_back(i);
    }
  }

  //rep(i,res.size()) cout << res[i] << " ";cout << endl;
  return res;
}

int main(){
  while(cin >> n >> m >> r, n){
    rep(i,n){
      s[i].resize(3);
      rep(j,3)cin >> s[i][j];
      cin >> sr[i];
    }
    
    rep(i,m){
      t[i].resize(3);
      rep(j,3)cin >> t[i][j];
      cin >> b[i];
    }

    e.resize(3);
    rep(i,3)cin >> e[i];

    vector<int> obj[20];
    rep(i,m){
      obj[i] = check(i);
    }
    
    D res = 0;
    rep(i,(1<<m)){
      vector<int> use(n);
      D sum = 0;
      rep(j,m){
	if( (i>>j)&1 ){
	  rep(k,obj[j].size()){
	    use[obj[j][k]] = 1;
	  }
	  sum += b[j] / dis2(e, t[j]);
	}
      }
      if(accumulate(use.begin(),use.end(),0) <= r){
	res = max(res, sum);
      }
    }
    cout << fixed << setprecision(10) << res << endl;
  }
}
  