### classes

class Pt3D
  attr_accessor :x, :y, :z

  def initialize() end
  def initialize(x, y, z) @x = x; @y = y; @z = z end

  def ==(pt) @x == pt.x && @y == pt.y && @z == pt.z end
  def +(pt) Pt3D.new(@x + pt.x, @y + pt.y, @z + pt.z) end
  def -(pt) Pt3D.new(@x - pt.x, @y - pt.y, @z - pt.z) end
  def -@() Pt3D.new(-@x, -@y, -@z) end
  def *(t) Pt3D.new(@x * t, @y * t, @z * t) end
  def /(t) Pt3D.new(@x / t, @y / t, @z / t) end
  def dot(v) @x * v.x + @y * v.y + @z * v.z end
  def cross(v)
    Pt3D.new(@y * v.z - @z * v.y, @z * v.x - @x * v.z, @x * v.y - @y * v.x)
  end
  def d2() @x * @x + @y * @y + @z * @z end
  def d() Math.sqrt(d2()) end
  def normalize() self / d() end
  def to_s() "(#{@x}, #{@y}, #{@z})" end
  def to_a() [@x, @y, @z] end
  #def hash() @y * W + @x end
end

### subroutines

def obst?(pt0, pt1, sc, sr)
  v0 = sc - pt0
  v1 = sc - pt1
  in0 = (v0.d2 < sr * sr)
  in1 = (v1.d2 < sr * sr)

  return false if in0 && in1
  return true if in0 || in1

  v01 = pt1 - pt0
  d = v0.cross(v1).d / v01.d
  return false if d > sr

  v0.dot(v01) > 0 && v1.dot(v01) < 0
end

### main

loop do
  n, m, r = gets.split.map(&:to_i)
  break if (n | m | r) == 0

  bcs = []
  brs = []
  n.times do
    sx, sy, sz, sr = gets.split.map(&:to_i)
    bcs << Pt3D.new(sx, sy, sz)
    brs << sr
  end

  lcs = []
  lbs = []
  m.times do
    tx, ty, tz, tb = gets.split.map(&:to_i)
    lcs << Pt3D.new(tx, ty, tz)
    lbs << tb
  end

  eye = Pt3D.new(*gets.split.map(&:to_i))
  #p eye.to_a

  lis = []
  for i in (0...m)
    lis << lbs[i].to_f / (lcs[i] - eye).d2
  end
  #p lis

  obsts = Array.new(m){[]}
  for i in (0...n)
    for j in (0...m)
      obsts[j] << i if obst?(eye, lcs[j], bcs[i], brs[i])
    end
  end
  #p obsts

  max_l = 0.0
  
  for bits in (0...(1 << m))
    sum = 0.0
    rn = 0
    rmvd = Array.new(n){false}
    
    for i in (0...m)
      if (bits & (1 << i)) != 0
        for oi in obsts[i]
          if ! rmvd[oi]
            rmvd[oi] = true
            rn += 1
          end
        end

        sum += lis[i]
      end
    end

    max_l = sum if rn <= r && max_l < sum
  end

  puts max_l
end