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

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}

// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

// std::vector Declaration and Initialization
template<typename T>
vector<T> make_vector(size_t a, T x) { return vector<T>(a, x); }
template<typename T, typename U, typename... Ts>
auto make_vector(size_t a, U b, Ts... ts) {
    return vector<decltype(make_vector<T>(b,ts...))>(a, make_vector<T>(b, ts...));
}

// std::vector Input
template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto &e : v) is >> e;
    return is;
}

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::array Debug
template<typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl

// Weighted edge
template<typename T>
struct edge {
    int src, to;
    T cost;

    edge() {}
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

using LL = int64_t;

#define fs first
#define sc second

const int64_t MOD = 1e9+7;


// 2-dim

using Point =  complex<double>;
using Segment = pair<Point, Point>;
double EPS = 1e-7;

double cross(const Point& a, const Point& b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

double dot(const Point& a, const Point& b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

bool is_intersected(
        const Point& a1, const Point& a2,
        const Point& b1, const Point& b2) {
    return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS and
           cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS;
}

bool is_intersected(const Segment& l1, const Segment& l2) {
    return is_intersected(l1.first, l1.second, l2.first, l2.second);
}

bool is_parallel(
        const Point &a1, const Point &a2,
        const Point &b1, const Point &b2) {
    return abs(cross(a1-a2, b1-b2)) < EPS;
}

bool is_parallel(const Segment& l1, const Segment& l2) {
    return is_parallel(l1.first, l1.second, l2.first, l2.second);
}

double distance_l_p(const Segment &l, const Point &c) {
    Point a = l.first, b = l.second;
    if (dot(b-a, c-a) < EPS) return abs(c-a);
    if (dot(a-b, c-b) < EPS) return abs(c-b);
    return abs(cross(b-a, c-a)) / abs(b-a);
}

double distance_ls(const Segment &l1, const Segment &l2) {
    bool parallel = is_parallel(l1, l2);
    bool intersect = is_intersected(l1, l2);
    if (!parallel and intersect) return 0;
    return min({
            distance_l_p(l1, l2.first),
            distance_l_p(l1, l2.second),
            distance_l_p(l2, l1.first),
            distance_l_p(l2, l1.second)});
}


// 3-dim

struct Point3D {
    double x, y, z;
    Point3D() {}
    Point3D(double x, double y, double z) : x(x), y(y), z(z) {}
    Point3D operator+(const Point3D& b) const {
        return Point3D(x + b.x, y + b.y, z + b.z);
    }
    Point3D operator-(const Point3D& b) const {
        return Point3D(x - b.x, y - b.y, z - b.z);
    }
    friend double norm(const Point3D& p) {
        return p.x * p.x + p.y * p.y + p.z * p.z;
    };
    friend double abs(const Point3D& p) { return sqrt(norm(p)); }

    friend ostream &operator<<(ostream &os, Point3D &p) {
        return os << "(" << p.x << "," << p.y << "," << p.z << ")";
    }
    friend istream &operator>>(istream &is, Point3D &p) {
        return is >> p.x >> p.y >> p.z;
    }
};
using Segment3D = pair<Point3D, Point3D>;

double dot(const Point3D &a, const Point3D &b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

Point3D cross(const Point3D &a, const Point3D &b) {
    double x = a.y * b.z - a.z * b.y,
           y = a.z * b.x - a.x * b.z,
           z = a.x * b.y - a.y * b.x;
    return Point3D(x, y, z);
}

bool is_parallel(
        const Point3D &a1, const Point3D &a2,
        const Point3D &b1, const Point3D &b2) {
    return abs(cross(a1-a2, b1-b2)) < EPS;
}

bool is_parallel(const Segment3D& l1, const Segment3D& l2) {
    return is_parallel(l1.first, l1.second, l2.first, l2.second);
}

double distance_l_p(const Segment3D &l, const Point3D &c) {
    Point3D a = l.first, b = l.second;
    if (dot(b-a, c-a) < EPS) return abs(c-a);
    if (dot(a-b, c-b) < EPS) return abs(c-b);
    return abs(cross(b-a, c-a)) / abs(b-a);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (true) {
        int N, M, R; cin >> N >> M >> R;
        if (N == 0) break;

        vector<Point3D> balloon(N);
        vector<double> r(N);
        for (int i = 0; i < N; ++i) {
            cin >> balloon[i] >> r[i];
        }

        vector<Point3D> light(M);
        vector<double> b(M);
        for (int i = 0; i < M; ++i) {
            cin >> light[i] >> b[i];
        }

        Point3D E; cin >> E;

        auto blocking = make_v<int>(M, N);
        for (int i = 0; i < M; ++i) {
            Segment3D l = { E, light[i] };
            for (int j = 0; j < N; ++j) {
                if (abs(E - balloon[j]) > r[j] and
                        abs(light[i] - balloon[j]) > r[j])
                {
                    if (distance_l_p(l, balloon[j]) - r[j] < EPS) {
                        blocking[i][j] = true;
                    }
                }
                else {
                    if (abs(E - balloon[j]) > r[j] xor
                            abs(light[i] - balloon[j]) > r[j]) {
                        blocking[i][j] = true;
                    }
                }
            }
        }

        vector<double> score(M);
        for (int i = 0; i < M; ++i) {
            score[i] = b[i] / norm(light[i] - E);
        }

        double ans = 0;
        for (int s = 0; s < 1<<M; ++s) {
            vector<int> blockingOr(N);
            double total = 0;
            for (int i = 0; i < M; ++i) if (s >> i & 1) {
                total += score[i];
                for (int j = 0; j < N; ++j) {
                    blockingOr[j] |= blocking[i][j];
                }
            }
            if (accumulate(blockingOr.begin(), blockingOr.end(), 0) <= R) {
                chmax(ans, total);
            }
        }

        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3484