In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.

The competition you participate in is to compete for the time it takes to destroy all the blue objects placed in the space. Athletes are allowed to bring in competition guns. In the space, there are multiple blue objects, the same number of red objects, and multiple obstacles. There is a one-to-one correspondence between the blue object and the red object, and the blue object must be destroyed by shooting a bullet at the blue object from the coordinates where the red object is placed. The obstacles placed in the space are spherical and the composition is slightly different, but if it is a normal bullet, the bullet will stop there when it touches the obstacle.

The bullet used in the competition is a special bullet called Magic Bullet. This bullet can store magical power, and when the bullet touches an obstacle, it automatically consumes the magical power, and the magic that the bullet penetrates is activated. Due to the difference in the composition of obstacles, the amount of magic required to penetrate and the amount of magic power consumed to activate it are different. Therefore, even after the magic for one obstacle is activated, it is necessary to activate another magic in order to penetrate another obstacle. Also, if the bullet touches multiple obstacles at the same time, magic will be activated at the same time. The amount of magical power contained in the bullet decreases with each magic activation.

While the position and size of obstacles and the amount of magical power required to activate the penetrating magic have already been disclosed, the positions of the red and blue objects have not been disclosed. However, the position of the object could be predicted to some extent from the information of the same competition in the past. You want to save as much magical power as you can, because putting magical power into a bullet is very exhausting. Therefore, assuming the position of the red object and the corresponding blue object, the minimum amount of magical power required to be loaded in the bullet at that time, that is, the magical power remaining in the bullet when reaching the blue object is 0. Let's find the amount of magical power that becomes.

Constraints

* 0 ≤ N ≤ 50
* 1 ≤ Q ≤ 50
* -500 ≤ xi, yi, zi ≤ 500
* 1 ≤ ri ≤ 1,000
* 1 ≤ li ≤ 1016
* -500 ≤ sxj, syj, szj ≤ 500
* -500 ≤ dxj, dyj, dzj ≤ 500
* Obstacles are never stuck in other obstacles
* The coordinates of the object are not inside or on the surface of the obstacle
* Under each assumption, the coordinates of the red object and the blue object do not match.

Input

All inputs are integers. Each number is separated by a single space.


N Q
x1 y1 z1 r1 l1
::
xN yN zN rN lN
sx1 sy1 sz1 dx1 dy1 dz1
::
sxQ syQ szQ dxQ dyQ dzQ


* N is the number of obstacles, and Q is the number of coordinates of the assumed blue and red objects.
* xi, yi, and zi are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the center of the i-th obstacle, respectively.
* ri is the radius of the i-th obstacle.
* li is the amount of magical power consumed by magic to penetrate the i-th obstacle.
* sxj, syj, and szj are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the red object in the jth assumption, respectively.
* dxj, dyj, and dzj are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the blue object in the jth assumption, respectively.

Output

Assuming the position of each pair of red objects and the corresponding blue objects, the amount of magical power to be loaded in the bullet is output on one line, assuming that there are only obstacles, red objects, and one pair of blue objects in space. Let's do it. The bullet is supposed to fly in a straight line from the position of the red object to the position of the blue object, and since the size of the bullet is very small, it is treated as a point.

Examples

Input

5 1
0 10 0 5 2
0 20 0 5 12
0 30 0 5 22
0 40 0 5 32
0 50 0 5 42
0 0 0 0 60 0


Output

110


Input

1 1
10 5 0 5 9
0 0 0 9 12 0


Output

9


Input

5 5
-38 -71 -293 75 1
-158 -38 -405 66 1
-236 -303 157 266 1
316 26 411 190 1
207 -312 -27 196 1
-50 292 -375 -401 389 -389
460 278 409 -329 -303 411
215 -220 -200 309 -474 300
261 -494 -87 -300 123 -463
386 378 486 -443 -64 299


Output

0
2
1
3
0

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
(N, Q) = map(int, input().split())
x = [None] * N
y = [None] * N
z = [None] * N
r = [None] * N
l = [None] * N
for i in range(N):
	(x[i], y[i], z[i], r[i], l[i]) = map(int, input().split())
for _ in range(Q):
	ans = 0
	(sx, sy, sz, dx, dy, dz) = map(int, input().split())
	vx = dx - sx
	vy = dy - sy
	vz = dz - sz
	for i in range(N):
		t = 0
		t += vx * (x[i] - sx)
		t += vy * (y[i] - sy)
		t += vz * (z[i] - sz)
		t /= vx ** 2 + vy ** 2 + vz ** 2
		len2 = 0
		len2 += (sx + vx * t - x[i]) ** 2
		len2 += (sy + vy * t - y[i]) ** 2
		len2 += (sz + vz * t - z[i]) ** 2
		if 0 < t < 1 and len2 <= r[i] ** 2 + 1e-09:
			ans += l[i]
	print(ans)


from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

def LI():
	return list(map(int, sys.stdin.readline().split()))

def I():
	return int(sys.stdin.readline())

def LS():
	return list(map(list, sys.stdin.readline().split()))

def S():
	return list(sys.stdin.readline())[:-1]

def IR(n):
	l = [None for i in range(n)]
	for i in range(n):
		l[i] = I()
	return l

def LIR(n):
	l = [None for i in range(n)]
	for i in range(n):
		l[i] = LI()
	return l

def SR(n):
	l = [None for i in range(n)]
	for i in range(n):
		l[i] = S()
	return l

def LSR(n):
	l = [None for i in range(n)]
	for i in range(n):
		l[i] = LS()
	return l
sys.setrecursionlimit(1000000)
mod = 1000000007

def A():
	n = I()
	s = 0
	ans = 'YES'
	for i in range(n):
		k = input()
		if k == 'Un':
			s -= 1
		else:
			s += 1
		if s < 0:
			ans = 'NO'
	if s:
		print('NO')
	else:
		print(ans)
	return

def B():
	return

def C():
	(n, q) = LI()
	p = LIR(n)
	for _ in range(q):
		(x0, y0, z0, s, t, u) = LI()
		(a, b, c) = (s - x0, t - y0, u - z0)
		ans = 0
		su = a ** 2 + b ** 2 + c ** 2
		for (xr, yr, zr, r, l) in p:
			x = (su - a ** 2) / su * x0 - a / su * (b * y0 + c * z0 - a * xr - b * yr - c * zr)
			y = (su - b ** 2) / su * y0 - b / su * (a * x0 + c * z0 - a * xr - b * yr - c * zr)
			z = (su - c ** 2) / su * z0 - c / su * (b * y0 + a * x0 - a * xr - b * yr - c * zr)
			if min(x0, s) - 0.0001 <= x <= max(x0, s) + 0.0001 and min(y0, t) - 0.0001 <= y <= max(y0, t) + 0.0001 and (min(z0, u) - 0.0001 <= z <= max(z0, u) + 0.0001):
				x -= xr
				y -= yr
				z -= zr
				r2 = x ** 2 + y ** 2 + z ** 2
				if r2 <= r ** 2 + 0.0001:
					ans += l
		print(ans)
	return

def D():
	return

def E():
	return

def F():
	return

def G():
	return

def H():
	return

def I_():
	return

def J():
	return
C()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]
ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, q) = LI()
	a = [LI() for _ in range(n)]
	b = [LI() for _ in range(q)]
	rr = []

	def k(a, b):
		return sum([(a[i] - b[i]) ** 2 for i in range(3)]) ** 0.5

	def f(a, b, c, r):
		ab = k(a, b)
		ac = k(a, c)
		bc = k(b, c)
		if ac <= r or bc <= r:
			return True
		at = ac ** 2 - r ** 2
		bt = bc ** 2 - r ** 2
		t = max(at, 0) ** 0.5 + max(bt, 0) ** 0.5
		return ab >= t - eps
	for (x1, y1, z1, x2, y2, z2) in b:
		tr = 0
		ta = (x1, y1, z1)
		tb = (x2, y2, z2)
		for (x, y, z, r, l) in a:
			if f(ta, tb, (x, y, z), r):
				tr += l
		rr.append(tr)
	return '\n'.join(map(str, rr))
print(main())


eps = 1.0 / 10 ** 10

def LI():
	return [int(x) for x in input().split()]

def main():
	(n, q) = LI()
	na = [LI() for _ in range(n)]
	qa = [LI() for _ in range(q)]
	rr = []

	def k(a, b):
		return sum([(a[i] - b[i]) ** 2 for i in range(3)]) ** 0.5

	def f(a, b, c, r):
		ab = k(a, b)
		ac = k(a, c)
		bc = k(b, c)
		if ac <= r or bc <= r:
			return True
		at = (ac ** 2 - r ** 2) ** 0.5
		bt = (bc ** 2 - r ** 2) ** 0.5
		return ab >= at + bt - eps
	for (x1, y1, z1, x2, y2, z2) in qa:
		tr = 0
		for (x, y, z, r, l) in na:
			if f((x1, y1, z1), (x2, y2, z2), (x, y, z), r):
				tr += l
		rr.append(tr)
	return '\n'.join(map(str, rr))
print(main())


import math

def sub(a, b):
	return [x - y for (x, y) in zip(a, b)]

def dot(a, b):
	return sum((x * y for (x, y) in zip(a, b)))

def cross(a, b):
	return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]

def abs2(a):
	return sum([x * x for x in a])

def deg(a, b):
	return math.acos(dot(a, b) / math.sqrt(abs2(a) * abs2(b)))
(N, Q) = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(N)]
for i in range(Q):
	(sx, sy, sz, dx, dy, dz) = map(int, input().split())
	cost = 0
	s = [sx, sy, sz]
	d = [dx, dy, dz]
	sd = sub(d, s)
	ds = sub(s, d)
	for v in ls:
		if abs(deg(sub(v[:3], s), sd)) < math.pi / 2 and abs(deg(sub(v[:3], d), ds)) < math.pi / 2:
			if abs2(cross(sub(v[:3], s), sd)) <= abs2(sd) * v[3] ** 2:
				cost += v[4]
		elif min(abs2(sub(v[:3], s)), abs2(sub(v[:3], d))) <= v[3] ** 2:
			cost += v[4]
	print(cost)