Read problems statements in Mandarin chinese, Russian and Vietnamese as well. 

Chef has to cross a highway with infinite length consisting of $N$ parallel lanes. The width of each lane is $Y$. Between each pair of adjacent lanes, there is a divider with negligible width; at each divider and the side of the highway, Chef can wait for an arbitrarily long time to allow the cars to pass by and then continue crossing the highway. Since Chef is lazy, he wants to cross the highway while walking the minimum possible distance; therefore, he will only move in a straight line perpendicular to the highway. Chef walks with a constant velocity $S$.

There is exactly one car in each lane. Each car is as wide as a whole lane (so it covers the entire width of its lane), has a known *length* and travels with fixed *velocity* in either direction along the highway. For each $i$ ($1 ≤ i ≤ N$), the car in the $i$-th lane has velocity $V_{i}$ and length $C_{i}$.

Let's measure distances along the highway, i.e. all points which lie on the same line perpendicular to the highway have the same coordinate $x$. Chef's position is $x=0$; for each $i$ ($1 ≤ i ≤ N$), the initial position of the car in the $i$-th lane is $P_{i}$ and the direction in which it's moving is $D_{i}$. If $D_{i} = 1$, the car is moving in the positive direction (its position is increasing) and if $D_{i} = 0$, the car is moving in the negative direction (its position is decreasing).

The drivers on a highway don't expect anyone to be crossing it, so they drive carelessly and won't be able to apply brakes at any point in time.

Find the minimum time Chef needs to cross the highway without getting hit by a car. Chef does not get hit by a car if the minimum distance between him and any car remains greater than $10^{-6}$ at all times.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains three space-separated integers $N$, $S$ and $Y$ denoting the number of lanes, Chef's walking speed and the width of a lane.
The second line contains $N$ space-separated integers $V_{1}, V_{2}, \dots, V_{N}$ denoting the absolute velocities of the cars.
The third line contains $N$ space-separated integers $D_{1}, D_{2}, \dots, D_{N}$ denoting the directions in which the cars are moving.
The fourth line contains $N$ space-separated integers $P_{1}, P_{2}, \dots, P_{N}$ denoting the initial positions of the cars. The position of a car is the $x$-coordinate of its front side, i.e. for a car moving in the positive direction, it is the largest coordinate of any point of the car, and for a car moving in the negative direction, it is the smallest coordinate of any point of the car.
The fifth line contains $N$ space-separated integers $C_{1}, C_{2}, \dots, C_{N}$ denoting the lengths of the cars.

------  Output ------
For each test case, print a single line containing one real number — the minimum time needed to cross the highway. Your answer will be considered correct if its absolute error does not exceed $10^{-3}$.

------  Constraints ------

$1 ≤ T ≤ 100,000$
$1 ≤ N ≤ 10$
$1 ≤ S ≤ 10$
$1 ≤ Y ≤ 1,000$
$1 ≤ V_{i} ≤ 200$ for each valid $i$
$0 ≤ D_{i} ≤ 1$ for each valid $i$
$|P_{i}| ≤ 10^{9}$ for each valid $i$
$1 ≤ C_{i} ≤ 1,000$ for each valid $i$

------  Subtasks ------
Subtask #1 (25 points): $N = 1$

Subtask #2 (75 points): original constraints

----- Sample Input 1 ------ 
3
2 6 6
5 10
1 0
-1 23
4 7
1 8 177
190
0
4201
21
1 1 1000
100
1
-100000
10
----- Sample Output 1 ------ 
4.000000
44.346053
2000.100000
----- explanation 1 ------ 
Example case 1: Chef has to wait at the side of the highway and allow the first car to pass. As soon as the car passes by, he can reach the first divider. At this divider, he has to wait again for the second car to pass. Chef's situation is drawn in the image.

Example case 2: We see that Chef needs time at least $\frac{177}{8} = 22.125$ to cross the highway, but the car would arrive at Chef's position at an earlier time $22.1105$. Hence, Chef must wait for the car to pass. Also, since Chef must wait until the car passes completely, he will wait for $\frac{4222}{190}=22.221053$ before starting to cross the lane. Hence, the total time taken to cross the highway is $44.346053$.

Example case 3: Chef can cross the road in time $1000$, but at that time, the car will reach $x=0$. Hence, at that moment, the distance between Chef and the car will be $0$, which is less than $10^{-6}$. Therefore, Chef has to wait for the car to pass before crossing.

Difficulty: MEDIUM_HARD
Tags: Geometry

Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
T = int(input())
for _ in range(T):
	(N, S, Y) = [int(c) for c in input().strip().split()]
	V = [int(c) for c in input().strip().split()]
	D = [int(c) * 2 - 1 for c in input().strip().split()]
	P = [int(c) for c in input().strip().split()]
	C = [int(c) for c in input().strip().split()]
	lane = 0
	t = 0
	tCross = Y / S
	while lane < N:
		f1 = P[lane] + V[lane] * D[lane] * t
		r1 = f1 - D[lane] * C[lane]
		f2 = f1 + V[lane] * D[lane] * tCross
		r2 = r1 + V[lane] * D[lane] * tCross
		tWait = 0
		if D[lane] == 1:
			if f1 >= -10 ** (-6) and r1 <= 10 ** (-6):
				tWait = (10 ** (-6) - r1) / V[lane]
			elif f2 >= -10 ** (-6) and r2 <= 10 ** (-6):
				tWait = (10 ** (-6) - r2) / V[lane] + tCross
			elif f1 < -10 ** (-6) and r2 > 10 ** (-6):
				tWait = tCross - (r2 - 10 ** (-6)) / V[lane]
		elif r1 >= -10 ** (-6) and f1 <= 10 ** (-6):
			tWait = (10 ** (-6) + r1) / V[lane]
		elif r2 >= -10 ** (-6) and f2 <= 10 ** (-6):
			tWait = (10 ** (-6) + r2) / V[lane] + tCross
		elif r2 < -10 ** (-6) and f1 > 10 ** (-6):
			tWait = tCross - (-r2 + 10 ** (-6)) / V[lane]
		t += tWait
		t += tCross
		lane += 1
	print(t)


t = int(input())
for deadman in range(t):
	ti = 0
	sm = 1e-06
	(n, s, y1) = [int(y) for y in input().split()]
	v = [int(y) for y in input().split()]
	d = [int(y) for y in input().split()]
	d = [-1 if x == 0 else x for x in d]
	p = [int(y) for y in input().split()]
	c = [int(y) for y in input().split()]
	t1 = y1 / s
	for x in range(n):
		car_t1 = p[x] + v[x] * d[x] * ti
		car_t2 = car_t1 + v[x] * d[x] * t1
		if d[x] == 1:
			if car_t2 <= -sm:
				ti += t1
			elif car_t1 - c[x] >= 0:
				ti += t1
			else:
				ti = (abs(p[x]) + c[x]) / v[x] + t1
		elif d[x] == -1:
			if car_t2 >= sm:
				ti += t1
			elif car_t1 + c[x] <= 0:
				ti += t1
			else:
				ti = (abs(p[x]) + c[x]) / v[x] + t1
	print(ti)


def revo(i):
	if P[i] > 0 and D[i] is 0 or (P[i] < 0 and D[i] is 1):
		ti = abs(P[i]) / V[i]
		tf = (abs(P[i]) + C[i]) / V[i]
		return [ti, tf]
	else:
		tf = (C[i] - abs(P[i])) / V[i]
		return [0, tf]

def check_route(i, t):
	(ti, tf) = revo(i)
	ti -= t
	tf -= t
	tc = W / S
	if (ti - tc) * V[i] > 1e-06 or tf < 0:
		return tc
	else:
		return tf + tc
for K in range(int(input())):
	(N, S, W) = list(map(int, input().split()))
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	t = 0.0
	for i in range(N):
		t = t + check_route(i, t)
	print('{0:.6f}'.format(t))


for i in range(int(input())):
	(n, s, y) = map(int, input().split())
	V_car = list(map(int, input().split()))
	Dir_car = list(map(int, input().split()))
	pos_car = list(map(int, input().split()))
	len_car = list(map(int, input().split()))
	t_chef = y / s
	ti = 0
	tolerance = 1e-06
	for i in range(n):
		d1 = pos_car[i] if Dir_car[i] is 0 else -pos_car[i]
		d2 = d1 + len_car[i]
		t_ce = d1 / V_car[i]
		t_cf = d2 / V_car[i]
		if d1 < 0:
			if t_cf + tolerance > ti + t_chef:
				ti = t_cf + t_chef
			else:
				ti += t_chef
		elif t_ce > ti + t_chef + tolerance or t_cf + tolerance < ti:
			ti += t_chef
		else:
			ti = t_cf + t_chef
	print(round(ti, 6))
exit(0)


t = int(input())
for i in range(t):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = 0
	x1 = 0
	y1 = 0
	for j in range(n):
		if d[j] == 1:
			x1 = p[j] + v[j] * time
			y1 = x1 - c[j]
			if x1 >= 0 and y1 <= -0:
				time += abs(1e-06 - y1) / v[j] + y / s
			elif x1 <= -1e-06:
				if x1 + y / s * v[j] > -1e-06:
					time += abs(1e-06 - y1) / v[j] + y / s
				else:
					time += y / s
			else:
				time += y / s
		else:
			x1 = p[j] - v[j] * time
			y1 = x1 + c[j]
			if x1 <= -1e-06 and y1 >= 1e-06:
				time += abs(y1 + 1e-06) / v[j] + y / s
			elif 1e-06 >= y1 >= -1e-06:
				time += abs(1e-06 + y1) / v[j] + y / s
			elif 1e-06 >= x1 >= -1e-06:
				time += abs(1e-06 + y1) / v[j] + y / s
			elif x1 >= 1e-06:
				if x1 - y / s * v[j] < 1e-06:
					time += abs(y1 + 1e-06) / v[j] + y / s
				else:
					time += y / s
			else:
				time += y / s
	print(time)


for _ in range(int(input())):
	(n, s, y) = [int(k) for k in input().split()]
	n = int(n)
	s = int(s)
	y = int(y)
	vel = [int(i) for i in input().split()]
	d = [int(z) for z in input().split()]
	p = [int(w) for w in input().split()]
	c = [int(a) for a in input().split()]
	c1 = y / s
	c2 = 0
	c3 = 0
	f = 10 ** (-6)
	for i in range(n):
		if d[i]:
			s = p[i] + vel[i] * c2
			if s < 0:
				s = abs(s)
				if s - vel[i] * c1 <= f:
					s += c[i] + f
					c3 += s / vel[i]
			elif c[i] + f > s:
				c3 += (c[i] + f - s) / vel[i]
		else:
			s = p[i] - vel[i] * c2
			if s >= 0:
				if s - vel[i] * c1 <= f:
					s += c[i] + f
					c3 += s / vel[i]
			else:
				s = abs(s)
				if c[i] + f > s:
					c3 += (c[i] + f - s) / vel[i]
		c3 += c1
		c2 = c3
	print(c3)


for t in range(int(input())):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	final = 0
	lelo = y / s
	for i in range(0, n):
		if p[i] > 0 and d[i] == 1:
			v[i] = -v[i]
		elif p[i] < 0 and d[i] == 0:
			v[i] = -v[i]
	for i in range(0, n):
		p[i] = abs(p[i])
	muhme = p[:]
	for i in range(0, n):
		time = 0
		if muhme[i] >= 0:
			if muhme[i] - v[i] * lelo > 1e-06:
				time += lelo
			elif muhme[i] - v[i] * lelo <= 1e-06 or muhme[i] <= 1e-06:
				time += (muhme[i] + c[i]) / v[i] + lelo
			else:
				time += lelo
		elif muhme[i] < 0:
			if abs(muhme[i]) < c[i]:
				time += (c[i] - abs(muhme[i])) / v[i] + lelo
			else:
				time += lelo
		else:
			time += lelo
		final += time
		for j in range(i + 1, n):
			muhme[j] = muhme[j] - v[j] * time
	print(final)


t = int(input())
for i in range(0, t):
	(n, s, w4) = map(int, input().split(' '))
	v4 = [int(x) for x in input().split(' ')]
	d4 = [int(x) for x in input().split(' ')]
	p = [int(x) for x in input().split(' ')]
	l = [int(x) for x in input().split(' ')]
	a = w4 / s
	e = 0
	for i in range(0, n):
		if d4[i] == 0:
			b = (a + e) * v4[i]
			h = e * v4[i]
			if p[i] - b > 1e-06:
				e = e + a
			elif p[i] + l[i] - h < -1e-06:
				e = e + a
			else:
				c = (abs(p[i] + l[i]) - e * v4[i] + 1e-06) / v4[i]
				e = c + e + a
		else:
			b = (a + e) * v4[i]
			h = e * v4[i]
			if p[i] + b < -1e-06:
				e = e + a
			elif p[i] - l[i] + h > 1e-06:
				e = e + a
			else:
				c = (abs(p[i] - l[i]) - e * v4[i] + 1e-06) / v4[i]
				e = c + e + a
	print('{:.6f}'.format(e))


for _ in range(int(input())):
	(n, s, path) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	starts = list(map(int, input().split()))
	lengths = list(map(int, input().split()))
	tchef = path / s
	i = 0
	final = 0
	while i < len(d):
		if d[i] == 1:
			end = starts[i] - lengths[i]
			if starts[i] <= 0 and end <= 0:
				treach = (0 - starts[i]) / v[i]
				tcross = (0 - end) / v[i]
			elif starts[i] > 0 and end < 0:
				treach = 0
				tcross = (0 - end) / v[i]
			else:
				treach = 10000000000000000000
				tcross = 10 * treach
		if d[i] == 0:
			end = starts[i] + lengths[i]
			if starts[i] >= 0 and end >= 0:
				treach = starts[i] / v[i]
				tcross = end / v[i]
			elif starts[i] < 0 and end > 0:
				treach = 0
				tcross = end / v[i]
			else:
				treach = 1000000000000000000000000000000
				tcross = 10 * treach
		if treach > tchef and abs(starts[i]) > 1e-06:
			final += tchef
		else:
			final += tchef + tcross
		try:
			if d[i + 1] == 1:
				starts[i + 1] += final * v[i + 1] + 1e-06
			else:
				starts[i + 1] -= final * v[i + 1] + 1e-06
		except:
			pass
		i += 1
	print(final)


t1 = int(input())
for i in range(0, t1):
	(n1, s1, w1) = map(int, input().split(' '))
	v1 = [int(x1) for x1 in input().split(' ')]
	d1 = [int(x1) for x1 in input().split(' ')]
	p1 = [int(x1) for x1 in input().split(' ')]
	l1 = [int(x1) for x1 in input().split(' ')]
	a1 = w1 / s1
	e1 = 0
	for i in range(0, n1):
		if d1[i] == 0:
			b1 = (a1 + e1) * v1[i]
			h1 = e1 * v1[i]
			if p1[i] - b1 > 1e-06:
				e1 = e1 + a1
			elif p1[i] + l1[i] - h1 < -1e-06:
				e1 = e1 + a1
			else:
				c1 = (abs(p1[i] + l1[i]) - e1 * v1[i] + 1e-06) / v1[i]
				e1 = c1 + e1 + a1
		else:
			b1 = (a1 + e1) * v1[i]
			h1 = e1 * v1[i]
			if p1[i] + b1 < -1e-06:
				e1 = e1 + a1
			elif p1[i] - l1[i] + h1 > 1e-06:
				e1 = e1 + a1
			else:
				c1 = (abs(p1[i] - l1[i]) - e1 * v1[i] + 1e-06) / v1[i]
				e1 = c1 + e1 + a1
	print('{:.6f}'.format(e1))


T = int(input())
for t in range(T):
	(N, S, Y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	time = 0
	for i in range(N):
		if D[i] == 1:
			P[i] += V[i] * time
		else:
			P[i] -= V[i] * time
		a = Y / S
		b = abs(P[i]) / V[i]
		t = 0
		if D[i] == 1:
			if P[i] >= 0:
				if P[i] < C[i]:
					t += abs(P[i] - C[i] - 1e-06) / V[i]
			elif a >= b:
				t += abs(P[i] - C[i] - 1e-06) / V[i]
		elif P[i] <= 0:
			if abs(P[i]) < C[i]:
				t += abs(P[i] + C[i] + 1e-06) / V[i]
		elif a >= b:
			t += abs(P[i] + C[i] + 1e-06) / V[i]
		t += Y / S
		time += t
	print('%.6f' % time)


for t in range(int(input())):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	total = 0
	con = y / s
	for i in range(0, n):
		if p[i] > 0 and d[i] == 1:
			v[i] = -v[i]
		elif p[i] < 0 and d[i] == 0:
			v[i] = -v[i]
	for i in range(0, n):
		p[i] = abs(p[i])
	temp = p[:]
	for i in range(0, n):
		time = 0
		if temp[i] >= 0:
			if temp[i] - v[i] * con > 1e-06:
				time += con
			elif temp[i] - v[i] * con <= 1e-06 or temp[i] <= 1e-06:
				time += (temp[i] + c[i]) / v[i] + con
			else:
				time += con
		elif temp[i] < 0:
			if abs(temp[i]) < c[i]:
				time += (c[i] - abs(temp[i])) / v[i] + con
			else:
				time += con
		else:
			time += con
		total += time
		for j in range(i + 1, n):
			temp[j] = temp[j] - v[j] * time
	print(round(total, 6))


t = int(input())
for _ in range(t):
	(n, s, y) = [int(x) for x in input().strip().split(' ')]
	t = y / s
	v = [int(x) for x in input().strip().split(' ')]
	d = [int(x) for x in input().strip().split(' ')]
	p = [int(x) for x in input().strip().split(' ')]
	c = [int(x) for x in input().strip().split(' ')]
	curr = 0
	for i in range(n):
		sign = -2 * d[i] + 1
		if curr + t < sign * p[i] / v[i] or curr > (1e-06 + c[i] + sign * p[i]) / v[i]:
			curr += t
		else:
			curr = (1e-06 + c[i] + sign * p[i]) / v[i] + t
	print(curr)


def mp():
	return map(int, input().split(' '))

def lst():
	return list(mp())
for w in range(int(input())):
	(n, s, d) = mp()
	t = d / s
	ans = 0
	v = lst()
	d = lst()
	p = lst()
	l = lst()
	r = 0
	to = 0
	for i in range(n):
		f = 0
		if p[i] <= 0 and d[i] == 1:
			r = -1 * p[i] / v[i]
			to = (-1 * p[i] + l[i]) / v[i]
		elif p[i] >= 0 and d[i] == 0:
			r = p[i] / v[i]
			to = (p[i] + l[i]) / v[i]
		else:
			ans += t
			f = 1
		if ans + t < r - 1e-06 and f == 0:
			ans += t
		elif ans >= to and f == 0:
			ans += t
		elif f == 0:
			ans = t + to
	print(ans)


t_c = int(input())
for i_t_c in range(t_c):
	(n, s, y) = map(int, input().split())
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ti = 0
	t = 0
	tc = y / s
	for i in range(n):
		ti = 0
		sw2 = 0
		sw3 = 0
		if p[i] - c[i] >= 0 and d[i] == 1 or (p[i] + c[i] <= 0 and d[i] == 0):
			ti = tc
		else:
			if p[i] > 0 and p[i] - c[i] < 0 and (d[i] == 1):
				sw2 = 1
			elif p[i] < 0 and p[i] + c[i] > 0 and (d[i] == 0):
				sw3 = 1
			if sw2 != 1 and sw3 != 1:
				if p[i] < 0:
					pc = -1 * p[i]
				else:
					pc = p[i]
				tv = (pc - pow(10, -6)) / v[i]
				if tv > tc:
					ti = tc
				else:
					tv = (pc + c[i]) / v[i]
					ti = tv + tc
			else:
				ti = (c[i] - abs(p[i])) / v[i] + tc
		t = t + ti
		for j in range(i + 1, n):
			if d[j] == 0:
				p[j] = p[j] - ti * v[j]
			else:
				p[j] = p[j] + ti * v[j]
	print(t)


t = int(input())
while t:
	numbers = [int(n) for n in input().split()]
	v = [int(n) for n in input().split()]
	d = [int(n) for n in input().split()]
	p = [int(n) for n in input().split()]
	c = [int(n) for n in input().split()]
	time_by_person = numbers[2] / numbers[1]
	total_time = 0
	for i in range(numbers[0]):
		if d[i]:
			p[i] = p[i] + total_time * v[i]
		else:
			p[i] = p[i] - total_time * v[i]
		if p[i] > 1e-06 and d[i] and (p[i] - c[i] < 0):
			total_time = total_time + ((c[i] - p[i]) * 1.0 + 1e-06) / v[i]
		elif p[i] < -1e-06 and (not d[i]) and (p[i] + c[i] > 0):
			total_time = total_time + ((p[i] + c[i]) * 1.0 + 1e-06) / v[i]
		elif abs(p[i]) < 1e-06:
			total_time = total_time + (c[i] * 1.0 + 2 * 1e-06 - abs(p[i])) / v[i]
		elif p[i] > 1e-06 and (not d[i]):
			timecar = (p[i] - 1e-06) / v[i]
			if timecar < time_by_person:
				total_time = total_time + ((p[i] + c[i]) * 1.0 + 1e-06) / v[i]
		elif p[i] < -1e-06 and d[i]:
			timecar = abs(p[i] + 1e-06) / v[i]
			if timecar < time_by_person:
				total_time = total_time + (abs(p[i] - c[i]) * 1.0 + 1e-06) / v[i]
		total_time += time_by_person
	print(format(total_time, '.6f'))
	t = t - 1


def change_pos_of_cars(x, velocity, direction, car_pos, i, n):
	for j in range(i + 1, n):
		displacement = x * velocity[i]
		if direction[i] == 1:
			car_pos[i] = car_pos[i] + displacement
		elif direction[i] == 0:
			car_pos[i] = car_pos[i] - displacement
t = int(input())
ans = []
while t > 0:
	nsy = [int(x) for x in input().split()]
	num_lanes = nsy[0]
	chef_speed = nsy[1]
	lane_width = nsy[2]
	velocity = [int(x) for x in input().split()]
	direction = [int(x) for x in input().split()]
	car_pos = [int(x) for x in input().split()]
	car_length = [int(x) for x in input().split()]
	total_time = 0
	chef_time = lane_width / chef_speed
	for i in range(num_lanes):
		if direction[i] == 1:
			car_back_pos = car_pos[i] - car_length[i]
			if car_pos[i] < -1e-06:
				disatance = -1e-06 - car_pos[i]
				time = disatance / velocity[i]
				if time > chef_time:
					total_time = total_time + chef_time
					x = chef_time
				else:
					total_time = total_time + chef_time + (0 - car_back_pos) / velocity[i]
					x = chef_time + (0 - car_back_pos) / velocity[i]
			elif car_back_pos > 0:
				total_time = total_time + chef_time
				x = chef_time
			else:
				total_time = total_time + chef_time + (0 - car_back_pos) / velocity[i]
				x = chef_time + (0 - car_back_pos) / velocity[i]
		elif direction[i] == 0:
			car_back_pos = car_pos[i] + car_length[i]
			if car_pos[i] > 1e-06:
				distance = car_pos[i] - 1e-06
				time = distance / velocity[i]
				if time > chef_time:
					total_time = total_time + chef_time
					x = chef_time
				else:
					total_time = total_time + chef_time + car_back_pos / velocity[i]
					x = chef_time + car_back_pos / velocity[i]
			elif car_back_pos < 0:
				total_time = total_time + chef_time
				x = chef_time
			else:
				total_time = total_time + chef_time + car_back_pos / velocity[i]
				x = chef_time + car_back_pos / velocity[i]
		for j in range(i, num_lanes):
			displacement = x * velocity[j]
			if direction[j] == 1:
				car_pos[j] = car_pos[j] + displacement
			elif direction[j] == 0:
				car_pos[j] = car_pos[j] - displacement
	ans.append(total_time)
	t = t - 1
for x in ans:
	print(x)


t = int(input())
while t > 0:
	(lanes, speed, width) = [int(i) for i in input().split()]
	car_vel = [int(i) for i in input().split()]
	car_dir = [int(i) for i in input().split()]
	car_pos = [int(i) for i in input().split()]
	car_len = [int(i) for i in input().split()]
	time = 0
	time_lane = width / speed
	for i in range(0, lanes):
		chef_pass = True
		car_dis_t = time * car_vel[i]
		car_dis = (time + time_lane) * car_vel[i]
		if car_dir[i] == 1:
			car_pos_f = car_pos[i] + car_dis
			car_pos_r = car_pos_f - car_len[i]
			car_pos_f_t = car_pos[i] + car_dis_t
			car_pos_r_t = car_pos_f_t - car_len[i]
			if car_pos_r_t < 0 and car_pos_f + 1e-06 >= 0:
				chef_pass = False
			if chef_pass == False:
				time += (0 - car_pos_r_t) / car_vel[i]
		else:
			car_pos_f = car_pos[i] - car_dis
			car_pos_r = car_pos_f + car_len[i]
			car_pos_f_t = car_pos[i] - car_dis_t
			car_pos_r_t = car_pos_f_t + car_len[i]
			if car_pos_r_t > 0 and car_pos_f - 1e-06 <= 0:
				chef_pass = False
			if chef_pass == False:
				time += car_pos_r_t / car_vel[i]
		time += time_lane
	print(round(time, 6))
	t -= 1


from sys import stdin, stdout

def chef_needs_wait(new_car_front_pos, cur_car_back_pos, d):
	val = 10 ** (-6)
	if d == 1:
		if new_car_front_pos < -val or cur_car_back_pos > val:
			return False
		return True
	else:
		if new_car_front_pos > val or cur_car_back_pos < -val:
			return False
		return True
for _ in range(int(stdin.readline().strip())):
	(n, s, y) = map(int, stdin.readline().strip().split())
	v = list(map(int, stdin.readline().strip().split()))
	d = list(map(int, stdin.readline().strip().split()))
	p = list(map(int, stdin.readline().strip().split()))
	c = list(map(int, stdin.readline().strip().split()))
	ans = 0
	late = 0
	chef_time = 0
	time_req = y / s
	chef_car_dist = 10 ** (-6)
	for i in range(n):
		if d[i] == 1:
			cur_car_front_pos = chef_time * v[i] + p[i]
			cur_car_back_pos = cur_car_front_pos - c[i]
			new_car_front_pos = time_req * v[i] + cur_car_front_pos
			new_car_back_pos = new_car_front_pos - c[i]
			if chef_needs_wait(new_car_front_pos, cur_car_back_pos, d[i]):
				wait_time = (chef_car_dist - cur_car_back_pos) / v[i]
				chef_time += wait_time
			chef_time += time_req
		else:
			cur_car_front_pos = p[i] - chef_time * v[i]
			cur_car_back_pos = cur_car_front_pos + c[i]
			new_car_front_pos = cur_car_front_pos - time_req * v[i]
			new_car_back_pos = new_car_front_pos + c[i]
			if chef_needs_wait(new_car_front_pos, cur_car_back_pos, d[i]):
				wait_time = (cur_car_back_pos - chef_car_dist) / v[i]
				chef_time += wait_time
			chef_time += time_req
	print(chef_time)


t = int(input())
for _ in range(t):
	(n, s, y) = [int(i) for i in input().split()]
	v = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	temp = []
	for i in range(n):
		if p[i] < 0 and d[i] == 0 or (p[i] - c[i] > 0 and d[i] == 1):
			temp.append((-1, -1))
		else:
			temp.append((abs(p[i]) / v[i], (abs(p[i]) + c[i]) / v[i]))
	ct = y / s
	tt = 0
	for i in range(n):
		if temp[i][0] == -1 or tt + ct + 1e-06 < temp[i][0] or tt + 1e-06 > temp[i][1]:
			tt += ct
		else:
			tt = temp[i][1] + ct
	print(tt)


minGap = 1e-06
T = int(input())
for test_case in range(T):
	(N, S, Y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	tConst = Y / S
	time = 0
	for i in range(N):
		if D[i] == 1:
			P[i] += time * V[i]
			if P[i] - C[i] > minGap or (P[i] < -minGap and (abs(P[i]) - minGap) / V[i] >= tConst):
				time += tConst
			else:
				time += (minGap - (P[i] - C[i])) / V[i] + tConst
		else:
			P[i] -= time * V[i]
			if P[i] + C[i] < -minGap or (P[i] > minGap and (P[i] - minGap) / V[i] >= tConst):
				time += tConst
			else:
				time += (minGap + (P[i] + C[i])) / V[i] + tConst
	print('{0:.6f}'.format(time))


t = int(input())
for u in range(t):
	close = 1e-06
	ans = 0
	(N, S, Y) = map(int, input().split())
	cheft = Y / S
	V = [int(i) for i in input().split()]
	D = [int(i) for i in input().split()]
	P = [int(i) for i in input().split()]
	C = [int(i) for i in input().split()]
	for i in range(N):
		if D[i] == 0:
			if P[i] < 0:
				if -P[i] - C[i] > close:
					ans += cheft
				else:
					ans += cheft
					tim_car = (close + P[i] + C[i]) / V[i]
					ans += tim_car
			elif P[i] > 0:
				if P[i] > close:
					tim_car = (P[i] - close) / V[i]
					if tim_car > cheft:
						ans += cheft
					else:
						ans += cheft
						tim_car = (P[i] + close + C[i]) / V[i]
						ans += tim_car
				else:
					ans += cheft
					tim_car = (P[i] + close + C[i]) / V[i]
					ans += tim_car
			else:
				ans += cheft
				ans += (close + C[i]) / V[i]
		elif D[i] == 1:
			if P[i] > 0:
				if P[i] - C[i] > close:
					ans += cheft
				else:
					ans += cheft
					tim_car = (close - P[i] + C[i]) / V[i]
					ans += tim_car
			elif P[i] < 0:
				if -P[i] > close:
					tim_car = (-P[i] - close) / V[i]
					if tim_car > cheft:
						ans += cheft
					else:
						ans += cheft
						tim_car = (-P[i] + close + C[i]) / V[i]
						ans += tim_car
				else:
					ans += cheft
					tim_car = (-P[i] + close + C[i]) / V[i]
					ans += tim_car
			else:
				ans += cheft
				ans += (close + C[i]) / V[i]
		if i != N - 1:
			shift = ans * V[i + 1]
			if D[i + 1] == 0:
				P[i + 1] -= shift
			else:
				P[i + 1] += shift
	print(round(ans, 6))


t = int(input().strip())
for i in range(t):
	(n, s, y) = [int(x) for x in input().strip().split(' ')]
	v = [int(x) for x in input().strip().split(' ')]
	d = [int(x) for x in input().strip().split(' ')]
	p = [int(x) for x in input().strip().split(' ')]
	c = [int(x) for x in input().strip().split(' ')]
	m = 0
	for i in range(n):
		if d[i] == 1:
			p[i] += m * v[i]
			if p[i] > 0:
				if p[i] >= c[i]:
					m += y / s
				else:
					m += y / s + (c[i] - p[i] + 1e-06) / v[i]
			elif -p[i] / v[i] <= y / s:
				m += y / s + (-p[i] + c[i] + 1e-06) / v[i]
			else:
				m += y / s
		else:
			p[i] -= m * v[i]
			if p[i] > 0:
				if p[i] / v[i] <= y / s:
					m += y / s + (p[i] + c[i] + 1e-06) / v[i]
				else:
					m += y / s
			elif p[i] <= -c[i]:
				m += y / s
			else:
				m += y / s + (c[i] + p[i] + 1e-06) / v[i]
	print('%.6f' % round(m, 6))


n = int(input())
for i in range(0, n):
	(t, s, y) = map(int, input().split(' '))
	velocity = [int(x) for x in input().split(' ')]
	di = [int(x) for x in input().split(' ')]
	pos = [int(x) for x in input().split(' ')]
	length = [int(x) for x in input().split(' ')]
	b = y / s
	e = 0
	for i in range(0, t):
		if di[i] == 0:
			a = (b + e) * velocity[i]
			height = e * velocity[i]
			if pos[i] - a > 1e-06:
				e = e + b
			elif pos[i] + length[i] - height < -1e-06:
				e = e + b
			else:
				c = (abs(pos[i] + length[i]) - e * velocity[i] + 1e-06) / velocity[i]
				e = c + e + b
		else:
			a = (b + e) * velocity[i]
			height = e * velocity[i]
			if pos[i] + a < -1e-06:
				e = e + b
			elif pos[i] - length[i] + height > 1e-06:
				e = e + b
			else:
				c = (abs(pos[i] - length[i]) - e * velocity[i] + 1e-06) / velocity[i]
				e = c + e + b
	print('{:.6f}'.format(e))


we = int(input())
for i in range(0, we):
	(n, s, w) = map(int, input().split(' '))
	v = [int(x) for x in input().split(' ')]
	d = [int(x) for x in input().split(' ')]
	p = [int(x) for x in input().split(' ')]
	l = [int(x) for x in input().split(' ')]
	a = w / s
	time = 0
	for i in range(0, n):
		if d[i] == 0:
			b = (a + time) * v[i]
			h = time * v[i]
			if p[i] - b > 1e-06:
				time = time + a
			elif p[i] + l[i] - h < -1e-06:
				time = time + a
			else:
				c = (abs(p[i] + l[i]) - time * v[i] + 1e-06) / v[i]
				time = c + time + a
		else:
			b = (a + time) * v[i]
			h = time * v[i]
			if p[i] + b < -1e-06:
				time = time + a
			elif p[i] - l[i] + h > 1e-06:
				time = time + a
			else:
				c = (abs(p[i] - l[i]) - time * v[i] + 1e-06) / v[i]
				time = c + time + a
	print('{:.6f}'.format(time))


debug = 0
V106 = pow(10, -6)

def currentPosOfCar(lane, time):
	if dirOfCars[lane] == 0:
		dirCar = -1
	else:
		dirCar = 1
	currentPos = posOfCars[lane] + dirCar * velOfCars[lane] * time
	return currentPos

def canPass(lane, time, timeNeeded):
	currentPos = currentPosOfCar(lane, time)
	if dirOfCars[lane] == 0:
		dirCar = -1
	else:
		dirCar = 1
	posAfter = currentPos + dirCar * velOfCars[lane] * timeNeeded
	if dirCar == 1 and posAfter < -1 * V106:
		return True
	if dirCar == -1 and posAfter > V106:
		return True
	return False

def letCarPass(lane, time):
	currentPos = currentPosOfCar(lane, time)
	if dirOfCars[lane] == 1:
		requiredPos = V106 + lenghtOfCars[lane]
	else:
		requiredPos = (V106 + lenghtOfCars[lane]) * -1
	dis = abs(requiredPos - currentPos)
	timeToPass = dis / velOfCars[lane]
	if debug:
		print('time to let pass', timeToPass)
	return timeToPass

def timeToWait(lane, time):
	currentPos = currentPosOfCar(lane, time)
	if dirOfCars[lane] == 1 and currentPos > V106 + lenghtOfCars[lane]:
		waitingTime = 0
	elif dirOfCars[lane] == 0 and currentPos < (V106 + lenghtOfCars[lane]) * -1:
		waitingTime = 0
	elif canPass(lane, time, timeNeeded):
		waitingTime = 0
	else:
		waitingTime = letCarPass(lane, time)
	if debug:
		print('waiting time', waitingTime)
	return waitingTime

def timeToCross(lane, time, timeNeeded):
	timeTaken = timeToWait(lane, time)
	timeTaken += timeNeeded
	return timeTaken
T = int(input())
for i in range(T):
	(N, S, Y) = map(int, input().split())
	velOfCars = [float(x) for x in input().split()]
	dirOfCars = [float(x) for x in input().split()]
	posOfCars = [float(x) for x in input().split()]
	lenghtOfCars = [float(x) for x in input().split()]
	time = 0
	timeNeeded = float(Y / S)
	if debug:
		print('time needed', timeNeeded)
	for i in range(N):
		time += timeToCross(i, time, timeNeeded)
	print(float('{0:.6f}'.format(time)))


import math
r = int(input())
while r is not 0:
	tt = 0
	(b, o, y1) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	jt = y1 / o
	tt = 0
	for i in range(b):
		if d[i] == 0:
			pos = p[i] - tt * a[i]
			if pos >= 0 and a[i] * jt + 1e-06 > pos:
				tt += (pos + c[i]) / a[i] + jt
			elif pos <= 0 and math.fabs(pos) <= c[i]:
				tt += (c[i] - math.fabs(pos)) / a[i] + jt
			else:
				tt += jt
		else:
			pos = p[i] + tt * a[i]
			if pos <= 0 and a[i] * jt + 1e-06 > math.fabs(pos):
				tt += (math.fabs(pos) + c[i]) / a[i] + jt
			elif pos >= 0 and pos <= c[i]:
				tt += (c[i] - pos) / a[i] + jt
			else:
				tt += jt
	print(tt)
	r -= 1


import math
t = int(input())
for i in range(0, t):
	(n, s, w) = map(int, input().split(' '))
	v = [int(x) for x in input().split(' ')]
	d = [int(x) for x in input().split(' ')]
	p = [int(x) for x in input().split(' ')]
	l = [int(x) for x in input().split(' ')]
	a = w / s
	e = 0
	for i in range(0, n):
		if d[i] == 0:
			p[i] = p[i] - v[i] * e
			if p[i] >= 0 and a * v[i] + 1e-06 > p[i]:
				e = e + a + (p[i] + l[i]) / v[i]
			elif p[i] <= 0 and math.fabs(p[i]) <= l[i]:
				e = e + a + (l[i] - math.fabs(p[i])) / v[i]
			else:
				e = e + a
		else:
			p[i] = p[i] + e * v[i]
			if p[i] <= 0 and v[i] * a + 1e-06 > math.fabs(p[i]):
				e = e + a + (math.fabs(p[i]) + l[i]) / v[i]
			elif p[i] >= 0 and p[i] <= l[i]:
				e = e + (l[i] - p[i]) / v[i] + a
			else:
				e = e + a
	print('{:.6f}'.format(e))


T = int(input())
for t in range(T):
	(N, S, Y) = map(int, input().split())
	vel = list(map(int, input().split()))
	dirL = list(map(int, input().split()))
	posL = list(map(int, input().split()))
	LenL = list(map(int, input().split()))
	if N == 1:
		time = Y / S
		if dirL[0] == 1:
			if not (posL[0] - LenL[0] > 1e-06 or (-posL[0] - 1e-06) / vel[0] > Y / S):
				time += (-posL[0] + LenL[0] + 1e-06) / vel[0]
		elif not (posL[0] + LenL[0] < -1e-06 or (posL[0] - 1e-06) / vel[0] > Y / S):
			time += (posL[0] + LenL[0] + 1e-06) / vel[0]
	else:
		time = 0
		for i in range(N):
			tcr = LenL[i] / vel[i]
			if dirL[i] == 1:
				nfrpos = posL[i] + vel[i] * time
				nbkpos = posL[i] - LenL[i] + vel[i] * time
				if (-nfrpos - 1e-06) / vel[i] < Y / S and nfrpos < -1e-06:
					time += (-nbkpos + 1e-06) / vel[i]
				elif nfrpos > 0 and nbkpos < 0:
					time += (-nbkpos + 1e-06) / vel[i]
			else:
				nfrpos = posL[i] - vel[i] * time
				nbkpos = posL[i] + LenL[i] - vel[i] * time
				if (nfrpos - 1e-06) / vel[i] < Y / S and nfrpos > 1e-06:
					time += (nbkpos + 1e-06) / vel[i]
				elif nfrpos < 0 and nbkpos > 0:
					time += (nbkpos + 1e-06) / vel[i]
			time += Y / S
	print(time)


t = int(input())
for asd in range(t):
	(n, s, y) = input().split()
	n = int(n)
	s = int(s)
	y = int(y)
	vel = []
	d = []
	p = []
	lengths = []
	time = 0.0
	vel = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	lengths = list(map(int, input().split()))
	crosstime = y / s
	for i in range(n):
		currfront = 0.0
		currback = 0.0
		if d[i] == 1:
			currfront = p[i] + vel[i] * time
			currback = currfront - lengths[i]
		else:
			currfront = p[i] - vel[i] * time
			currback = currfront + lengths[i]
		if currfront * (1 if d[i] == 1 else -1) >= 0:
			if currback * (1 if d[i] == 1 else -1) >= 0:
				time += crosstime
			else:
				time += (abs(currback) + 1e-06) / vel[i]
				time += crosstime
		elif abs(currfront) > 1e-06:
			arrivetime = (abs(currfront) - 1e-06) / vel[i]
			if arrivetime > crosstime:
				time += crosstime
			else:
				time += abs(currback) / vel[i]
				time += crosstime
		else:
			time += (abs(currback) + 1e-06) / vel[i]
			time += crosstime
	print(time)


import sys

def preprocess(n, velocities, directions, initial_positions):
	for i in range(0, n):
		if initial_positions[i] < 0:
			initial_positions[i] *= -1
			directions[i] = 0 if directions[i] == 1 else 1
		velocities[i] *= 1 if directions[i] == 1 else -1
	return (velocities, initial_positions)

def get_lane_time(chef_speed, lane_width, initial_position, velocity, car_length, time_lapsed_till_now):
	lane_time = lane_width / chef_speed
	current_start_pos = initial_position + velocity * time_lapsed_till_now
	if velocity > 0:
		if current_start_pos - car_length < 10 ** (-6):
			lane_time += (car_length - current_start_pos) / velocity
	elif current_start_pos > abs(velocity) * lane_time + 10 ** (-6) or current_start_pos + car_length < -10 ** (-6):
		pass
	else:
		lane_time += (current_start_pos + car_length) / abs(velocity)
	return lane_time

def solve(n, chef_speed, lane_width, velocities, directions, initial_positions, car_lengths):
	ans = 0
	(velocities, initial_positions) = preprocess(n, velocities, directions, initial_positions)
	for i in range(0, n):
		ans += get_lane_time(chef_speed, lane_width, initial_positions[i], velocities[i], car_lengths[i], ans)
	return ans
t = int(input())
while t > 0:
	(n, s, y) = [int(x) for x in input().split()]
	velocities = [int(x) for x in input().split()]
	directions = [int(x) for x in input().split()]
	initial_positions = [int(x) for x in input().split()]
	car_lengths = [int(x) for x in input().split()]
	print(solve(n, s, y, velocities, directions, initial_positions, car_lengths))
	t -= 1


for _ in range(int(input())):
	(n, s, y) = [int(x) for x in input().split()]
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	cost = 0
	for i in range(n):
		if d[i] == 0 and p[i] + c[i] <= 0 or (d[i] == 1 and p[i] - c[i] >= 0):
			cost += y / s
		elif d[i] == 1 and p[i] + cost * v[i] - c[i] > 0:
			cost += y / s
		elif d[i] == 1 and (p[i] * -1 - cost * v[i]) / v[i] - y / s > 1e-06:
			cost += y / s
		elif d[i] == 1 and (p[i] * -1 - cost * v[i]) / v[i] - y / s <= 1e-06:
			cost += abs(p[i] + cost * v[i] - c[i]) / v[i] + y / s
		elif d[i] == 0 and p[i] - cost * v[i] + c[i] < 0:
			cost += y / s
		elif d[i] == 0 and (p[i] - cost * v[i]) / v[i] - y / s > 1e-06:
			cost += y / s
		elif d[i] == 0 and (p[i] - cost * v[i]) / v[i] - y / s <= 1e-06:
			cost += (p[i] - cost * v[i] + c[i]) / v[i] + y / s
	print('%.6f' % cost)


T = int(input())
N = [0 for i in range(T)]
S = [0 for i in range(T)]
Y = [0 for i in range(T)]
V = [[] for i in range(T)]
D = [[] for i in range(T)]
P = [[] for i in range(T)]
C = [[] for i in range(T)]
time = [0 for i in range(T)]
for y in range(T):
	stri = input()
	l = stri.split()
	N[y] = int(l[0])
	S[y] = int(l[1])
	Y[y] = int(l[2])
	stri = input()
	l = stri.split()
	for u in l:
		V[y].append(int(u))
	stri = input()
	l = stri.split()
	for u in l:
		if u == '0':
			D[y].append(1)
		else:
			D[y].append(-1)
	stri = input()
	l = stri.split()
	for u in l:
		P[y].append(int(u))
	stri = input()
	l = stri.split()
	for u in l:
		d = int(u) + 1e-06
		C[y].append(d)
for y in range(T):
	t = 0
	for i in range(N[y]):
		if P[y][i] == 0:
			t = C[y][i] / V[y][i] + Y[y] / S[y]
		elif P[y][i] > 0 and D[y][i] < 0 or (P[y][i] < 0 and D[y][i] > 0):
			if abs(P[y][i]) < C[y][i]:
				t = (C[y][i] - abs(P[y][i])) / V[y][i] + Y[y] / S[y]
			else:
				t = Y[y] / S[y]
		elif (Y[y] + 1e-06) / S[y] > D[y][i] * P[y][i] / V[y][i]:
			t = (D[y][i] * P[y][i] + C[y][i]) / V[y][i] + Y[y] / S[y]
		else:
			t = Y[y] / S[y]
		time[y] = time[y] + t
		if i != N[y] - 1:
			P[y][i + 1] = P[y][i + 1] - D[y][i + 1] * time[y] * V[y][i + 1]
for f in time:
	print(f)


t = int(input())
e6 = 1e-06
while t:
	(n, s, y) = [int(x) for x in input().split()]
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	time = float(y) / s
	elapsed = 0.0
	for i in range(n):
		if d[i]:
			p[i] += elapsed * v[i]
			if p[i] - c[i] > e6:
				elapsed += time
			elif p[i] > -e6 and p[i] - c[i] < e6:
				elapsed += (c[i] - p[i]) / float(v[i]) + time
			elif p[i] + v[i] * time < -e6:
				elapsed += time
			elif p[i] < 0 and p[i] + v[i] * time > -e6:
				elapsed += (abs(p[i]) + c[i]) / float(v[i]) + time
			else:
				raise ValueError(i)
		else:
			p[i] -= elapsed * v[i]
			if p[i] + c[i] < -e6:
				elapsed += time
			elif p[i] < e6 and p[i] + c[i] > -e6:
				elapsed += (c[i] - abs(p[i])) / float(v[i]) + time
			elif p[i] - v[i] * time > e6:
				elapsed += time
			elif p[i] > 0 and p[i] - v[i] * time < e6:
				elapsed += (abs(p[i]) + c[i]) / float(v[i]) + time
			else:
				raise ValueError(i)
	print(elapsed)
	t -= 1


def update(time, lane):
	for j in range(lane, n):
		if direction[j] == 1:
			position[j] += time * velo[j]
		else:
			position[j] -= time * velo[j]

def sol():
	timecons = y / s
	time = 0
	i = 0
	while i < n:
		if direction[i] == 1:
			if position[i] > 0 and position[i] - length[i] < 0:
				time += timecons + abs(position[i] - length[i]) / velo[i]
				update(timecons + abs(position[i] - length[i]) / velo[i], i)
				i += 1
			elif position[i] <= 0 and abs(position[i]) / velo[i] <= timecons:
				time += timecons + abs(position[i] - length[i]) / velo[i]
				update(timecons + abs(position[i] - length[i]) / velo[i], i)
				i += 1
			else:
				time += timecons
				update(timecons, i)
				i += 1
		elif position[i] < 0 and position[i] + length[i] > 0:
			time += timecons + abs(position[i] + length[i]) / velo[i]
			update(timecons + abs(position[i] + length[i]) / velo[i], i)
			i += 1
		elif position[i] >= 0 and abs(position[i]) / velo[i] <= timecons:
			time += timecons + abs(position[i] + length[i]) / velo[i]
			update(timecons + abs(position[i] + length[i]) / velo[i], i)
			i += 1
		else:
			time += timecons
			update(timecons, i)
			i += 1
	print(time)
for i in range(int(input())):
	(n, s, y) = map(int, input().split())
	velo = list(map(int, input().split()))
	direction = list(map(int, input().split()))
	position = list(map(int, input().split()))
	for i in range(n):
		if position[i] > 0:
			position[i] -= pow(10, -6)
		else:
			position[i] += pow(10, -6)
	length = list(map(int, input().split()))
	sol()


from random import randint

def mi():
	return map(int, input().split())

def ii():
	return int(input())

def update(time, lane):
	for j in range(lane, n):
		if direction[j] == 1:
			position[j] += time * velo[j]
		else:
			position[j] -= time * velo[j]

def sol():
	timecons = y / s
	time = 0
	i = 0
	while i < n:
		if direction[i] == 1:
			if position[i] > 0 and position[i] - length[i] < 0:
				time += timecons + abs(position[i] - length[i]) / velo[i]
				update(timecons + abs(position[i] - length[i]) / velo[i], i)
				i += 1
			elif position[i] <= 0 and abs(position[i]) / velo[i] <= timecons:
				time += timecons + abs(position[i] - length[i]) / velo[i]
				update(timecons + abs(position[i] - length[i]) / velo[i], i)
				i += 1
			else:
				time += timecons
				update(timecons, i)
				i += 1
		elif position[i] < 0 and position[i] + length[i] > 0:
			time += timecons + abs(position[i] + length[i]) / velo[i]
			update(timecons + abs(position[i] + length[i]) / velo[i], i)
			i += 1
		elif position[i] >= 0 and abs(position[i]) / velo[i] <= timecons:
			time += timecons + abs(position[i] + length[i]) / velo[i]
			update(timecons + abs(position[i] + length[i]) / velo[i], i)
			i += 1
		else:
			time += timecons
			update(timecons, i)
			i += 1
	print(time)
for i in range(ii()):
	(n, s, y) = mi()
	velo = list(mi())
	direction = list(mi())
	position = list(mi())
	for i in range(n):
		if position[i] > 0:
			position[i] -= pow(10, -6)
		else:
			position[i] += pow(10, -6)
	length = list(mi())
	sol()


t = int(input())
for _ in range(t):
	chef = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = 0
	chef_time = chef[2] / chef[1]
	for i in range(chef[0]):
		if d[i] == 1:
			p[i] += v[i] * time
			if p[i] < 0:
				time1 = abs(p[i]) / v[i]
				time2 = (abs(p[i]) + c[i]) / v[i]
				if time1 - chef_time >= 1e-06:
					time += chef_time
				else:
					time += time2 + chef_time
			elif p[i] >= 0 and p[i] - c[i] < 0:
				time2 = abs(p[i] - c[i]) / v[i]
				time += time2 + chef_time
			else:
				time += chef_time
		else:
			p[i] -= v[i] * time
			if p[i] > 0:
				time1 = p[i] / v[i]
				time2 = (p[i] + c[i]) / v[i]
				if time1 - chef_time >= 1e-06:
					time += chef_time
				else:
					time += time2 + chef_time
			elif p[i] <= 0 and p[i] + c[i] > 0:
				time2 = (p[i] + c[i]) / v[i]
				time += time2 + chef_time
			else:
				time += chef_time
	print(time)


t = int(input())
for i in range(t):
	(N, S, Y) = map(int, input().split())
	velocities = list(map(int, input().split()))
	directions = list(map(int, input().split()))
	positions = list(map(int, input().split()))
	lengths = list(map(int, input().split()))
	time = 0
	for j in range(N):
		if directions[j] == 1:
			positions[j] += velocities[j] * time
			if positions[j] - lengths[j] > 1e-06 or (positions[j] < 0 and -1e-06 > Y * velocities[j] / S + positions[j]):
				time += Y / S
			else:
				time += (-positions[j] + lengths[j]) / velocities[j] + Y / S
		else:
			positions[j] -= velocities[j] * time
			if positions[j] + lengths[j] < -1e-06 or (positions[j] > 0 and 1e-06 < -Y * velocities[j] / S + positions[j]):
				time += Y / S
			else:
				time += (positions[j] + lengths[j]) / velocities[j] + Y / S
	print(time)


t = int(input())
for z in range(t):
	(n, s, y) = [int(x) for x in input().split()]
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	tm = 0
	ct = y / s
	for i in range(n):
		if d[i]:
			if p[i] + v[i] * tm < -1e-06:
				if v[i] * (tm + ct) + p[i] < -1e-06:
					tm += ct
				else:
					tm += ct + abs(p[i] - c[i] + v[i] * tm) / v[i]
			elif p[i] - c[i] + v[i] * tm > 1e-06:
				tm += ct
			else:
				tm += ct + abs(p[i] + v[i] * tm - c[i]) / v[i]
		elif p[i] - v[i] * tm > 1e-06:
			if p[i] - v[i] * tm - v[i] * ct > 1e-06:
				tm += ct
			else:
				tm += ct + (p[i] - v[i] * tm + c[i]) / v[i]
		elif p[i] - v[i] * tm + c[i] < -1e-06:
			tm += ct
		else:
			tm += ct + (p[i] - v[i] * tm + c[i]) / v[i]
	print(tm)


t = int(input())
err = pow(10, -6)
for _ in range(t):
	(n, s, y) = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = [1 if i == '1' else -1 for i in input().split()]
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = 0
	cross_time = y / s
	for i in range(n):
		veh_pos = p[i] + d[i] * time * v[i]
		if d[i] == -1 and veh_pos + c[i] < err or (d[i] == 1 and veh_pos - c[i] > err):
			time += cross_time
		elif abs(veh_pos) / v[i] - cross_time > err and veh_pos * d[i] < err:
			time += cross_time
		else:
			time += abs(veh_pos - d[i] * c[i]) / v[i] + cross_time
	print('%f' % time)


t = int(input())
while t > 0:
	(n, chefv, y) = map(int, input().split())
	v = list(map(int, input().split()))
	di = list(map(int, input().split()))
	p = list(map(int, input().split()))
	cl = list(map(int, input().split()))
	totime = 0.0
	for i in range(n):
		if di[i] == 0:
			di[i] = -1
		temptime = y / chefv
		cartime = (abs(0 - p[i]) - totime * v[i]) / v[i]
		diff = 1e-06 / v[i]
		pcar = p[i] + totime * v[i] * di[i]
		if di[i] == 1 and p[i] > cl[i] or (di[i] == -1 and p[i] < -cl[i]):
			totime += temptime
		elif cartime + diff + cl[i] / v[i] <= 0 or cartime - diff >= temptime:
			totime += temptime
		else:
			totime += temptime + cartime + cl[i] / v[i]
	print('%.6f' % totime)
	t -= 1


for _ in range(int(input())):
	(n, chef_speed, lane_length) = map(int, input().split())
	velocity = list(map(int, input().split()))
	direction = list(map(int, input().split()))
	position = list(map(int, input().split()))
	car_length = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		dist = ans * velocity[i]
		if direction[i]:
			position[i] += dist
		else:
			position[i] -= dist
		chef_time = lane_length / chef_speed
		if direction[i] and position[i] - car_length[i] < 0:
			if position[i] >= 0:
				ans += abs(position[i] - car_length[i]) / velocity[i]
				ans += lane_length / chef_speed
				continue
			elif lane_length / chef_speed >= abs(position[i]) / velocity[i] or abs(position[i] + chef_time * velocity[i]) < 10 ** (-6):
				ans += abs(position[i] - car_length[i]) / velocity[i]
				ans += lane_length / chef_speed
				continue
		if direction[i] == 0 and position[i] + car_length[i] > 0:
			if position[i] <= 0:
				ans += (position[i] + car_length[i]) / velocity[i]
				ans += lane_length / chef_speed
				continue
			elif lane_length / chef_speed >= position[i] / velocity[i] or abs(position[i] - chef_time * velocity[i]) < 10 ** (-6):
				ans += (position[i] + car_length[i]) / velocity[i]
				ans += lane_length / chef_speed
				continue
		ans += lane_length / chef_speed
	print(ans)


for z in range(int(input())):
	(n, s, y) = map(int, input().split())
	velocities = list(map(int, input().split()))
	directions = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	lengths = list(map(int, input().split()))
	time = 0
	for i in range(n):
		if directions[i] == 1:
			currentpos = pos[i] + time * velocities[i]
			if currentpos <= 0:
				if (abs(currentpos) - 10 ** (-6)) / velocities[i] > y / s:
					time += y / s
				else:
					time += (abs(currentpos) + lengths[i] + 10 ** (-6)) / velocities[i] + y / s
			elif currentpos <= lengths[i] + 10 ** (-6):
				time += (lengths[i] - currentpos + 10 ** (-6)) / velocities[i] + y / s
			else:
				time += y / s
		elif directions[i] == 0:
			currentpos = pos[i] - time * velocities[i]
			if currentpos >= 0:
				if (currentpos - 10 ** (-6)) / velocities[i] > y / s:
					time += y / s
				else:
					time += (abs(currentpos) + lengths[i] + 10 ** (-6)) / velocities[i] + y / s
			elif abs(currentpos) <= lengths[i] + 10 ** (-6):
				time += (lengths[i] + currentpos + 10 ** (-6)) / velocities[i] + y / s
			else:
				time += y / s
	print(time)


import math
t = int(input())
while t is not 0:
	tt = 0
	(n, s, y) = [int(x) for x in input().split()]
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	jt = y / s
	tt = 0
	for i in range(n):
		if d[i] == 0:
			pos = p[i] - tt * v[i]
			if pos >= 0 and v[i] * jt + 1e-06 > pos:
				tt += (pos + c[i]) / v[i] + jt
			elif pos <= 0 and math.fabs(pos) <= c[i]:
				tt += (c[i] - math.fabs(pos)) / v[i] + jt
			else:
				tt += jt
		else:
			pos = p[i] + tt * v[i]
			if pos <= 0 and v[i] * jt + 1e-06 > math.fabs(pos):
				tt += (math.fabs(pos) + c[i]) / v[i] + jt
			elif pos >= 0 and pos <= c[i]:
				tt += (c[i] - pos) / v[i] + jt
			else:
				tt += jt
	print(tt)
	t -= 1


def update(index, time, arrival_time, departure_time):
	for i in range(index, n):
		departure_time[i] -= time
		arrival_time[i] -= time

def arrival(n, direction, position, velocity):
	arr_time = []
	for car in range(n):
		if direction[car]:
			if position[car] + x >= 0:
				arr_time.append(0)
			else:
				temp = abs(position[car] + x) / velocity[car]
				arr_time.append(temp)
		elif position[car] - x <= 0:
			arr_time.append(0)
		else:
			temp = abs(position[car] - x) / velocity[car]
			arr_time.append(temp)
	return arr_time

def departure(n, direction, position, velocity, length):
	dep_time = []
	for car in range(n):
		if direction[car]:
			if position[car] - length[car] + x >= 0:
				dep_time.append(0)
			else:
				temp = abs(position[car] - length[car] + x) / velocity[car]
				dep_time.append(temp)
		elif position[car] + length[car] - x <= 0:
			dep.time.append(0)
		else:
			temp = abs(position[car] + length[car] - x) / velocity[car]
			dep_time.append(temp)
	return dep_time

def totaltime(arrival_time, departure_time, chef_time):
	total_time = 0
	for car in range(n):
		if arrival_time[car] <= 0 and departure_time[car] <= 0:
			total_time += chef_time
			update(car + 1, chef_time, arrival_time, departure_time)
		elif arrival_time[car] <= 0:
			total_time += departure_time[car] + chef_time
			update(car + 1, departure_time[car] + chef_time, arrival_time, departure_time)
		elif chef_time < arrival_time[car]:
			total_time += chef_time
			update(car + 1, chef_time, arrival_time, departure_time)
		elif chef_time > arrival_time[car]:
			total_time += departure_time[car] + chef_time
			update(car + 1, departure_time[car] + chef_time, arrival_time, departure_time)
	return total_time
x = 1e-06
for _ in range(int(input())):
	(n, s, y) = map(int, input().split())
	vel = list(map(int, input().split()))
	dirn = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	leng = list(map(int, input().split()))
	c_time = y / s
	arrival_time = arrival(n, dirn, pos, vel)
	departure_time = departure(n, dirn, pos, vel, leng)
	print(totaltime(arrival_time, departure_time, c_time))


T = int(input())
for _ in range(T):
	(N, S, Y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	person_time = Y / S
	total_time = 0
	total_time_prev = 0
	for i in range(N):
		if D[i] == 0:
			V[i] = -V[i]
	for i in range(N):
		if P[i] == 0:
			total_time += person_time
			total_time += C[i] / V[i]
		elif D[i] == 1 and P[i] - C[i] > 10 ** (-6):
			total_time += person_time
		elif D[i] == 0 and P[i] + C[i] < -10 ** (-6):
			total_time += person_time
		elif D[i] == 1 and P[i] + person_time * V[i] < -10 ** (-6):
			total_time += person_time
		elif D[i] == 0 and P[i] + person_time * V[i] > 10 ** (-6):
			total_time += person_time
		elif D[i] == 1 and P[i] > 0 and (P[i] - C[i] - 10 ** (-6) < 0):
			total_time += person_time
			total_time += (C[i] - P[i] + 10 ** (-6)) / abs(V[i])
		elif D[i] == 0 and P[i] < 0 and (P[i] + C[i] + 10 ** (-6) > 0):
			total_time += person_time
			total_time += (C[i] + P[i] + 10 ** (-6)) / abs(V[i])
		else:
			total_time += person_time
			total_time += (abs(P[i]) + C[i] + 10 ** (-6)) / abs(V[i])
		for j in range(N):
			P[j] = P[j] + (total_time - total_time_prev) * V[j]
		total_time_prev = total_time
	print('%.6f' % total_time)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = 0
	chefT = a[2] / a[1]
	for i in range(a[0]):
		if d[i] == 1 and p[i] > 0 and (time * v[i] + p[i] - c[i] > 10 ** (-6)):
			time += chefT
		else:
			if p[i] < 0 and d[i] == 1:
				p[i] = -1 * p[i]
			B = p[i] - (time + chefT) * v[i]
			A = p[i] - time * v[i]
			if B >= 10 ** (-6) or A + c[i] <= -10 ** (-6):
				time += chefT
			else:
				time += chefT + (A + c[i]) / v[i]
	print(time)


for _ in range(int(input())):
	t_total = 0
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	t_chef = y / s
	for i in range(n):
		if p[i] > 0 and d[i] == 0:
			current_pos = p[i] - v[i] * t_total
		elif p[i] <= 0 and d[i] == 1:
			current_pos = p[i] + v[i] * t_total
		elif p[i] > 0 and d[i] == 1:
			current_pos = p[i] + v[i] * t_total
		elif p[i] <= 0 and d[i] == 0:
			current_pos = p[i] - v[i] * t_total
		t_car = abs(current_pos) / v[i]
		if d[i] == 0 and current_pos < 0 and (abs(current_pos) >= c[i]) or (d[i] == 1 and current_pos > 0 and (current_pos >= c[i])):
			t_total += t_chef
			continue
		if d[i] == 0 and current_pos < 0 and (abs(current_pos) < c[i]):
			t_total += t_chef + (c[i] + current_pos) / v[i]
			continue
		if d[i] == 1 and current_pos > 0 and (current_pos < c[i]):
			t_total += t_chef + (c[i] - current_pos) / v[i]
			continue
		if t_chef < t_car:
			t_total += t_chef
			continue
		t_total += t_chef + (abs(current_pos) + c[i] + pow(10, -6)) / v[i]
	print('%.6f' % t_total)


t = int(input())
for aaa in range(t):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(n):
		d[i] = 2 * d[i] - 1
	vc = y / s
	t1 = [0 for i in range(2)]
	t = [[0, 0] for i in range(n)]
	for i in range(n):
		t[i][0] = (-d[i] * p[i] - 10 ** (-6)) / v[i]
		t[i][1] = t[i][0] + c[i] / v[i] + 2 * (10 ** (-6) / v[i])
	cur = 0.0
	for i in range(n):
		if cur >= t[i][1] or cur + vc <= t[i][0]:
			cur = cur + vc
		else:
			cur = t[i][1] + vc
	print('%.6f' % cur)


def increment_distances(pos, inc, dir, idx, velo):
	for j in range(idx + 1, n):
		if dir[j] == 0:
			pos[j] -= velo[j] * inc
		else:
			pos[j] += velo[j] * inc
t = int(input())
while t > 0:
	ip = input().split()
	n = int(ip[0])
	s = int(ip[1])
	y = int(ip[2])
	chef_time = y / s
	inc = 0
	elap_time = 0
	midi = 10 ** (-6)
	velo = list(map(int, input().split()))
	dir = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	length = list(map(int, input().split()))
	for i in range(n):
		if dir[i] == 0 and pos[i] + length[i] <= 0 or (dir[i] == 1 and pos[i] - length[i] >= 0):
			inc = chef_time
			elap_time += inc
		elif pos[i] == 0:
			inc = length[i] / velo[i] + chef_time
			elap_time += inc
		elif dir[i] == 0:
			if pos[i] - chef_time * velo[i] > midi and pos[i] > 0:
				inc = chef_time
				elap_time += inc
			elif pos[i] < 0 and pos[i] + length[i] > 0:
				rem = pos[i] + length[i]
				inc = chef_time + rem / velo[i]
				elap_time += inc
			else:
				inc = chef_time + (pos[i] + length[i]) / velo[i]
				elap_time += inc
		elif abs(pos[i]) - velo[i] * chef_time > midi and pos[i] < 0:
			inc = chef_time
			elap_time += inc
		elif pos[i] > 0 and pos[i] - length[i] < 0:
			rem = length[i] - pos[i]
			inc = chef_time + rem / velo[i]
			elap_time += inc
		else:
			inc = chef_time + (abs(pos[i]) + length[i]) / velo[i]
			elap_time += inc
		increment_distances(pos, inc, dir, i, velo)
	print('%.6lf' % elap_time)
	t -= 1


t = int(input())
while t:
	t -= 1
	(n, s, y) = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = 0
	req = y * 1.0 / s
	for i in range(n):
		di = -1
		if d[i] == 1:
			di = 1
		oldhead = p[i] + ans * 1.0 * v[i] * di
		newhead = oldhead + req * 1.0 * v[i] * di
		oldtail = oldhead - c[i] * di
		newtail = newhead - c[i] * di
		if oldtail <= 0 and oldtail >= -1e-06 or (oldtail >= 0 and oldtail <= 1e-06):
			now = 1e-06 - oldtail * di
			if now < 0:
				now = -now
			ans += now / v[i]
		elif newhead > 0 and oldhead < 0 or (newhead < 0 and oldhead > 0) or (newtail > 0 and oldtail < 0) or (newtail < 0 and oldtail > 0) or (newhead <= 0 and newhead >= -1e-06) or (newhead >= 0 and newhead <= 1e-06) or (newtail <= 0 and newtail >= -1e-06) or (newtail >= 0 and newtail <= 1e-06) or (oldhead <= 0 and oldhead >= -1e-06) or (oldhead >= 0 and oldhead <= 1e-06) or (oldhead < 0 and oldtail > 0) or (oldtail < 0 and oldhead > 0):
			if oldtail < 0:
				oldtail = -oldtail
			oldtail += 1e-06
			ans += oldtail * 1.0 / v[i]
		ans += req
	print(ans)


import math
import sys
for t in range(int(input())):
	finalTime = 0
	nsy = list(map(int, input().rstrip().split(' ')))
	n = int(nsy[0])
	s = int(nsy[1])
	y = int(nsy[2])
	v = list(map(int, input().rstrip().split(' ')))
	d = list(map(int, input().rstrip().split(' ')))
	p = list(map(int, input().rstrip().split(' ')))
	c = list(map(int, input().rstrip().split(' ')))
	for i in range(0, n):
		curTime = 0
		if p[i] >= 0 and p[i] <= c[i] and (d[i] == 1):
			curTime = (c[i] - p[i]) / v[i]
		elif p[i] <= 0 and p[i] + c[i] >= 0 and (d[i] == 0):
			curTime = (c[i] + p[i]) / v[i]
		elif p[i] <= 0 and d[i] == 1 or (p[i] >= 0 and d[i] == 0):
			if abs(p[i]) / v[i] <= y / s or abs(p[i]) - v[i] * (y / s) <= 1e-06:
				curTime = (abs(p[i]) + c[i]) / v[i]
		j = i + 1
		while j <= n - 1:
			if p[j] <= 0 and d[j] == 1:
				p[j] = p[j] + v[j] * (curTime + y / s)
			elif p[j] <= 0 and d[j] == 0:
				p[j] = p[j] - v[j] * (curTime + y / s)
			elif p[j] >= 0 and d[j] == 1:
				p[j] = p[j] + v[j] * (curTime + y / s)
			elif p[j] >= 0 and d[j] == 0:
				p[j] = p[j] - v[j] * (curTime + y / s)
			j += 1
		finalTime += curTime
	print(finalTime + y / s * n)


for _ in range(int(input())):
	(n, s, y) = map(int, input().split())
	t = 0
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(n):
		if d[i]:
			if p[i] > 0 and p[i] - c[i] - 1e-06 >= 0:
				t += y / s
			elif p[i] > 0 and p[i] - c[i] == 0:
				t += y / s + 1e-06 / v[i]
			elif p[i] > 0 and p[i] - c[i] - 1e-06 < 0:
				t += y / s + abs(p[i] - c[i] - 1e-06) / v[i]
			elif abs(p[i]) / v[i] <= y / s:
				t += y / s + (abs(p[i]) + c[i] + 1e-06) / v[i]
			else:
				t += y / s
		elif p[i] < 0 and p[i] + c[i] + 1e-06 <= 0:
			t += y / s
		elif p[i] < 0 and p[i] + c[i] == 0:
			t += y / s + 1e-06 / v[i]
		elif p[i] < 0 and p[i] + c[i] + 1e-06 > 0:
			t += y / s + (p[i] + c[i] + 1e-06) / v[i]
		elif p[i] / v[i] <= y / s:
			t += y / s + (p[i] + c[i] + 1e-06) / v[i]
		else:
			t += y / s
		if i < n - 1 and d[i + 1]:
			p[i + 1] += t * v[i + 1]
		elif i < n - 1:
			p[i + 1] -= t * v[i + 1]
	print(round(t, 6))


import math
t = int(input())
while t != 0:
	(n, s, y) = map(int, input().split(' '))
	v = list(map(int, input().split(' ')))
	d = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	tim = 0
	tem = y / s
	i = 0
	while i < n:
		T1 = (abs(p[i]) - 1e-06) / abs(v[i])
		T2 = (abs(p[i]) + c[i] + 1e-06) / abs(v[i])
		if T1 - tim > tem or (p[i] < 0 and d[i] == 0) or (p[i] > 0 and d[i] == 1):
			tim = tim + tem
		elif T2 <= tim:
			tim = tim + tem
		else:
			tim = T2 + tem
		i = i + 1
	print(tim)
	t = t - 1


t = int(input())
for i in range(t):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	temp = 1e-06
	time = 0
	man = y / s
	for j in range(n):
		if d[j] == 0:
			ub = p[j] - time * v[j]
			lb = ub + c[j]
			if ub < -temp and lb < -temp:
				time = time + man
				continue
			if ub <= 0 and lb >= 0:
				time = time + man + abs(lb) / v[j] + temp / v[j]
				continue
			if ub <= temp and ub >= 0:
				time = time + man + ub / v[j] + c[j] / v[j] + temp / v[j]
				continue
			if lb > 0 and lb <= temp:
				time = time + man + abs(lb) / v[j] + temp / v[j]
				continue
			if lb <= 0 and lb >= -temp:
				time = time + man + (temp - abs(lb)) / v[j]
				continue
			if ub < -temp and lb > temp:
				time = time + man + abs(lb) / v[j] + temp / v[j]
				continue
			if ub > temp and lb > temp:
				xy = ub - temp
				xy = xy / v[j]
				ff = xy - man
				if ff > 0:
					time = time + man
				else:
					time = time + man + ub / v[j] + c[j] / v[j] + temp / v[j]
				continue
		else:
			ub = p[j] + time * v[j]
			lb = ub - c[j]
			if ub > temp and lb > temp:
				time = time + man
				continue
			if ub >= 0 and lb <= 0:
				time = time + man + abs(lb) / v[j] + temp / v[j]
				continue
			if ub >= temp and ub <= 0:
				time = time + man - ub / v[j] + c[j] / v[j] + temp / v[j]
				continue
			if lb < 0 and lb > -temp:
				time = time + man + abs(lb) / v[j]
				continue
			if lb >= 0 and lb <= temp:
				time = time + man + (temp - abs(lb)) / v[j]
				continue
			if ub > temp and lb < -temp:
				time = time + man + abs(lb) / v[j] + temp / v[j]
				continue
			if ub < -temp and lb < -temp:
				xy = -ub - temp
				xy = xy / v[j]
				ff = xy - man
				if ff > 0:
					time = time + man
				else:
					time = time + man - ub / v[j] + c[j] / v[j] + temp / v[j]
				continue
	print(time)


T = int(input())

def Pt(P0, Vi, Di, t):
	if Di == 0:
		return P0 - Vi * t
	return P0 + Vi * t
for _ in range(T):
	(N, S, Y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	wt = 0
	dt = Y / S
	for i in range(N):
		t = Y * i / S + wt
		pt = Pt(P[i], V[i], D[i], t)
		if D[i] == 1:
			if pt - C[i] < 0 and (not (pt < 0 and pt + dt * V[i] < -1e-06)):
				wt += abs(pt - C[i]) / V[i]
		elif pt + C[i] > 0 and (not (pt > 0 and pt - dt * V[i] > 1e-06)):
			wt += abs(pt + C[i]) / V[i]
	print(Y * N / S + wt)


t = int(input())
for testcase in range(t):
	(n, s, y) = list(map(int, input().split(' ')))
	vlist = list(map(int, input().split(' ')))
	dlist = list(map(int, input().split(' ')))
	plist = list(map(int, input().split(' ')))
	clist = list(map(int, input().split(' ')))
	time = 0.0
	tlane = y / s
	for i in range(n):
		if dlist[i] == 1:
			if plist[i] + vlist[i] * (time + tlane) < -1e-06 or plist[i] + vlist[i] * time - clist[i] > 1e-06:
				time += tlane
			else:
				pnew = plist[i] + vlist[i] * time
				time += (clist[i] - pnew + 1e-06) / vlist[i]
				time += tlane
		elif plist[i] - vlist[i] * (time + tlane) > 1e-06 or plist[i] - vlist[i] * time + clist[i] < -1e-06:
			time += tlane
		else:
			pnew = plist[i] - vlist[i] * time
			time += (clist[i] + pnew + 1e-06) / vlist[i]
			time += tlane
	print('{0:.6f}'.format(time))


t = int(input())
for q in range(0, t):
	var = [int(w) for w in input().split()]
	n = var[0]
	s = var[1]
	y = var[2]
	v = [int(w) for w in input().split()]
	d = [int(w) for w in input().split()]
	p = [int(w) for w in input().split()]
	c = [int(w) for w in input().split()]
	timen = y * n / s
	time1 = y / s
	timet = 0
	ti = []
	to = []
	p_p = 1e-06
	p_n = -1e-06
	for i in range(0, n):
		if d[i] == 1:
			if p[i] - c[i] >= p_p:
				ti.append(9999999999)
				to.append(-999999999)
			elif p[i] >= p_n and p[i] - c[i] <= p_p:
				ti.append(0)
				to.append(abs(c[i] - p[i]) / v[i])
			else:
				ti.append((0 - p[i]) / v[i])
				to.append((c[i] + abs(p[i])) / v[i])
		if d[i] == 0:
			if p[i] + c[i] <= p_n:
				ti.append(9999999999)
				to.append(-999999999)
			elif p[i] <= p_p and p[i] + c[i] >= p_n:
				ti.append(0)
				to.append(abs(p[i] + c[i]) / v[i])
			else:
				ti.append(p[i] / v[i])
				to.append((c[i] + p[i]) / v[i])
	for i in range(0, n):
		if timet > to[i] or timet + time1 < ti[i]:
			timet = timet + time1
		else:
			timet = to[i] + time1 + p_p / v[i]
	print(timet)


def sameside(a, b):
	if a > 1e-06 and b > 1e-06 or (a < -1e-06 and b < -1e-06):
		return True
	else:
		return False
test = int(input())
while test > 0:
	(n, s, y) = map(int, input().split())
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	passtime = y / s
	totime = 0
	(fone, bone, ftwo, btwo) = (0, 0, 0, 0)
	for i in range(n):
		temptime = totime + passtime
		if d[i] == 0:
			fone = p[i] - v[i] * totime
			bone = fone + c[i]
			ftwo = p[i] - v[i] * temptime
			btwo = ftwo + c[i]
		else:
			fone = p[i] + v[i] * totime
			bone = fone - c[i]
			ftwo = p[i] + v[i] * temptime
			btwo = ftwo - c[i]
		if sameside(fone, ftwo) and sameside(bone, btwo) and sameside(fone, bone):
			totime += passtime
		else:
			totime += abs(bone) / v[i]
			totime += passtime
	print(totime)
	test = test - 1


for _ in range(int(input())):
	(n, s, yy) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	y = list(map(int, input().split()))
	l = list(map(int, input().split()))
	t = yy / s
	ans = 0
	for i in range(n):
		if d[i] == 1:
			dis = v[i] * ans
			y[i] += dis
			start = y[i]
			last = y[i] - l[i]
			if last >= 0:
				ans += t
			elif start > 0:
				dd = abs(last)
				ans += dd / v[i]
				ans += t
			elif start >= -1e-06:
				ans += l[i] / v[i]
				ans += t
			else:
				df = abs(start) - 1e-06
				tf = df / v[i]
				dl = abs(last)
				tl = dl / v[i]
				if tf > t:
					ans += t
				else:
					ans += tl
					ans += t
		else:
			dis = v[i] * ans
			y[i] -= dis
			start = y[i]
			last = y[i] + l[i]
			if last <= 0:
				ans += t
			elif start < 0:
				dd = last
				ans += dd / v[i]
				ans += t
			elif start <= 1e-06:
				ans += l[i] / v[i]
				ans += t
			else:
				df = start - 1e-06
				tf = df / v[i]
				dl = last
				tl = dl / v[i]
				if tf > t:
					ans += t
				else:
					ans += tl
					ans += t
	print(ans)


for t0 in range(int(input())):
	(N, S, Y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	b_P = []
	for i in range(N):
		if D[i] == 1:
			b_P.append(P[i] - C[i])
		else:
			b_P.append(P[i] + C[i])
	(t, t_wc) = (0, Y / S)
	for i in range(N):
		if D[i] == 1:
			P[i] += t * V[i]
			b_P[i] = P[i] - C[i]
			if b_P[i] >= 1e-06:
				t += t_wc
			else:
				t_c = -P[i] / V[i]
				if t_c <= t_wc:
					t += t_wc + (-b_P[i] + 1e-06) / V[i]
				else:
					t += t_wc
		if D[i] == 0:
			P[i] -= t * V[i]
			b_P[i] = P[i] + C[i]
			if b_P[i] <= -1e-06:
				t += t_wc
			else:
				t_c = P[i] / V[i]
				if t_c <= t_wc:
					t += t_wc + (b_P[i] + 1e-06) / V[i]
				else:
					t += t_wc
	print('%.6f' % t)


import math
t = int(input())
while t != 0:
	(n, s, y) = map(int, input().split(' '))
	v = list(map(int, input().split(' ')))
	d = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	tim = 0
	time1 = y / s
	i = 0
	while i < n:
		timec1 = (abs(p[i]) - 1e-06) / abs(v[i])
		timec2 = (abs(p[i]) + c[i] + 1e-06) / abs(v[i])
		if timec1 - tim > time1 or (p[i] < 0 and d[i] == 0) or (p[i] > 0 and d[i] == 1):
			tim = tim + time1
		elif timec2 <= tim:
			tim = tim + time1
		else:
			tim = timec2 + time1
		i = i + 1
	print(tim)
	t = t - 1


T = int(input())
for test_case in range(T):
	(N, S, Y) = [int(n) for n in input().split(' ')]
	V = [int(n) for n in input().split(' ')]
	D = [int(n) for n in input().split(' ')]
	P = [int(n) for n in input().split(' ')]
	C = [int(n) for n in input().split(' ')]
	T_elapsed = 0
	for lane in range(N):
		if D[lane]:
			C_min = P[lane] - C[lane] + V[lane] * T_elapsed
			C_max = P[lane] + Y / S * V[lane] + V[lane] * T_elapsed
		else:
			C_min = P[lane] - Y / S * V[lane] - V[lane] * T_elapsed
			C_max = P[lane] + C[lane] - V[lane] * T_elapsed
		if 0 < C_min or 0 > C_max:
			T_elapsed = T_elapsed + Y / S
			continue
		elif D[lane]:
			T_elapsed = T_elapsed + Y / S + abs(C_min - 0) / V[lane] + 1e-05
		else:
			T_elapsed = T_elapsed + Y / S + abs(C_max - 0) / V[lane] + 1e-05
	print(T_elapsed)


for _ in range(int(input())):
	(n, s, y) = [int(c) for c in input().split()]
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	cheftime = y / s
	time = ans = 0
	r = 10 ** (-6)
	for i in range(n):
		if d[i]:
			dist = p[i] + v[i] * time
			if dist < 0:
				dist = abs(dist)
				if dist - v[i] * cheftime <= r:
					dist += c[i] + r
					ans += dist / v[i]
			elif c[i] + r > dist:
				ans += (c[i] + r - dist) / v[i]
		else:
			dist = p[i] - v[i] * time
			if dist >= 0:
				if dist - v[i] * cheftime <= r:
					dist += c[i] + r
					ans += dist / v[i]
			else:
				dist = abs(dist)
				if c[i] + r > dist:
					ans += (c[i] + r - dist) / v[i]
		ans += cheftime
		time = ans
	print(ans)


test = int(input())
while test > 0:
	test -= 1
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = y / s
	ctime = 0
	for i in range(n):
		if d[i] == 1:
			dist = p[i] + ctime * v[i] + 1e-06
			dist1 = dist - c[i] - 1e-06
			if dist1 > 0:
				ctime += time
			elif dist > 0 and dist1 < 0:
				ctime += time + abs(dist1) / v[i]
			else:
				t = abs(dist) / v[i]
				if time < t:
					ctime += time
				else:
					ctime += time + abs(dist1) / v[i]
		else:
			dist = p[i] - ctime * v[i] - 1e-06
			dist1 = dist + c[i] + 1e-06
			if dist1 < 0:
				ctime += time
			elif dist < 0 and dist1 < 0:
				ctime += time + dist1 / v[i]
			else:
				t = dist / v[i]
				if time < t:
					ctime += time
				else:
					ctime += time + dist1 / v[i]
	print(ctime)


T = int(input())
for t in range(0, T):
	(n, s, y) = list(map(float, input().split()))
	n = int(n)
	tt = y / s
	v = list(map(float, input().split()))
	d = list(map(int, input().split()))
	p = list(map(float, input().split()))
	c = list(map(float, input().split()))
	ct = 0
	vt = 0
	for i in range(0, n):
		if d[i] == 1:
			ss = p[i] + ct * v[i]
			ct += tt
			if ss >= 0 and ss <= c[i]:
				ct = ct + (-ss + c[i]) / v[i] + 1e-07
			elif ss < 0:
				ss = -ss
				vt = ss / v[i]
				if vt <= tt:
					ct = ct + (ss + c[i]) / v[i] + 1e-07
		else:
			ss = p[i] - ct * v[i]
			ct += tt
			if ss <= 0 and ss >= -c[i]:
				ct = ct + (ss + c[i]) / v[i] + 1e-07
			elif ss > 0:
				vt = ss / v[i]
				if vt <= tt:
					ct = ct + (ss + c[i]) / v[i] + 1e-07
	print('%.6f' % ct)


t = input()
for i in range(int(t)):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	t = 0.0
	for i in range(n):
		if d[i] == 0 and p[i] >= 0 and (t < (abs(p[i]) + c[i]) / v[i]) or (d[i] == 1 and p[i] <= 0 and (t < (abs(p[i]) + c[i]) / v[i])):
			if y / s < (abs(p[i]) - 1e-06) / v[i] - t:
				t = t + y / s
			else:
				m = (abs(p[i]) + c[i]) / v[i] + y / s - t
				t = t + m
		else:
			t = t + y / s
	print('{0:.6f}'.format(t))


for _ in range(int(input())):
	(n, s, y) = [int(x) for x in input().split()]
	vs = [int(x) for x in input().split()]
	ds = [int(x) for x in input().split()]
	ps = [int(x) for x in input().split()]
	cs = [int(x) for x in input().split()]
	t = 0
	interval = y / s
	for (v, d, p, c) in zip(vs, ds, ps, cs):
		if d == 1:
			(t1, t2) = (-p / v, (c - p) / v)
		else:
			(t1, t2) = (p / v, (p + c) / v)
		if t + interval + 1e-06 / v <= t1:
			t += interval
		else:
			t = max(t2 + 1e-06 / v, t) + interval
	print(round(t, 6))


for _ in range(int(input())):
	(N, S, Y) = [int(x) for x in input().split()]
	V = [int(x) for x in input().split()]
	D = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	chefTime = Y / S
	totalTime = 0
	t = 0
	diff = 1e-06
	for i in range(N):
		if D[i] == 0:
			if P[i] < 0 and abs(P[i]) > C[i]:
				t = chefTime
				totalTime += t
			elif P[i] < 0 and C[i] - abs(P[i]) > 0:
				t = (C[i] - abs(P[i])) / V[i] + chefTime
				totalTime += t
			elif P[i] >= 0 and Y * V[i] > (P[i] - diff) * S:
				t = (C[i] + P[i] - diff) / V[i] + chefTime
				totalTime += t
			else:
				t = chefTime
				totalTime += t
		elif D[i] == 1:
			if P[i] > 0 and P[i] > C[i]:
				t = chefTime
				totalTime += t
			elif P[i] > 0 and C[i] - P[i] > 0:
				t = (C[i] - P[i]) / V[i] + chefTime
				totalTime += t
			elif P[i] <= 0 and Y * V[i] > (abs(P[i]) - diff) * S:
				t = (C[i] + abs(P[i]) - diff) / V[i] + chefTime
				totalTime += t
			else:
				t = chefTime
				totalTime += t
		for j in range(i + 1, N):
			if D[j] == 0:
				P[j] -= t * V[j]
			else:
				P[j] += t * V[j]
	print('{0:.6f}'.format(totalTime))


from decimal import Decimal
t = int(input())
for i in range(t):
	(n, s, y) = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = list(map(int, input().split()))
	cost = 0
	for j in range(n):
		pi = -p[j] if d[j] == 1 else p[j]
		wait = Decimal(pi) / Decimal(v[j]) - cost
		epsilon = Decimal(1e-06) / Decimal(v[j])
		if -Decimal(l[j]) / Decimal(v[j]) <= wait - epsilon < Decimal(y) / Decimal(s):
			cost += wait + Decimal(l[j]) / Decimal(v[j])
		cost += Decimal(y) / Decimal(s)
	print(cost)


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	t1 = x[2] / x[1]
	s = 0
	for i in range(x[0]):
		T = 0
		if d[i] == 0:
			k = p[i] - v[i] * s
			if k >= 0:
				t2 = k / v[i]
				if t2 > t1:
					if v[i] * (t2 - t1) <= 1e-06:
						t2 = (k + c[i]) / v[i]
						T = t2 + t1
					else:
						T = t1
				else:
					t2 = (k + c[i]) / v[i]
					T = t2 + t1
			elif k <= 0 < k + c[i]:
				t2 = (k + c[i]) / v[i]
				T = t1 + t2
			else:
				T = t1
		else:
			k = p[i] + v[i] * s
			if k <= 0:
				t2 = abs(k) / v[i]
				if t2 > t1:
					if v[i] * (t2 - t1) <= 1e-06:
						t2 = abs(k - c[i]) / v[i]
						T = t2 + t1
					else:
						T = t1
				else:
					t2 = abs(k - c[i]) / v[i]
					T = t2 + t1
			elif k >= 0 > k - c[i]:
				t2 = abs(k - c[i]) / v[i]
				T = t1 + t2
			else:
				T = t1
		s = s + T
	print('%.8f' % s)


for t in range(int(input())):
	(N, S, Y) = [int(x) for x in input().split()]
	V = [int(x) for x in input().split()]
	D = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	cheflane = Y / S
	(cartime, chefbest) = ([], 0)
	mind = 10 ** (-6)
	for x in range(N):
		(t0, t1) = (0, 0)
		if D[x] == 0:
			if P[x] - mind >= 0:
				t0 = (P[x] - mind) / V[x]
			if P[x] + mind + C[x] >= 0:
				t1 = (P[x] + mind + C[x]) / V[x]
		elif D[x] == 1:
			if P[x] + mind <= 0:
				t0 = (P[x] + mind) / V[x]
			if P[x] - mind - C[x] <= 0:
				t1 = (P[x] - mind - C[x]) / V[x]
		cartime.append((abs(t0), abs(t1)))
	for x in range(N):
		if chefbest + cheflane < cartime[x][0]:
			chefbest += cheflane
		elif chefbest < cartime[x][1]:
			chefbest += cartime[x][1] - chefbest + cheflane
		else:
			chefbest += cheflane
	print(chefbest)


t = int(input())
while t > 0:
	t = t - 1
	(n, s, y) = list(map(int, input().split(' ')))
	a = []
	for i in range(4):
		a.append([int(j) for j in input().split()])
	result = 0
	for i in range(n):
		v = 0
		end = 0
		if a[1][i] == 0:
			v = -a[0][i]
			end = a[2][i] + a[3][i]
		else:
			v = a[0][i]
			end = a[2][i] - a[3][i]
		st = (0 - a[2][i]) / v
		ed = (0 - end) / v
		if st - (result + y / s) > 1e-06 / a[0][i]:
			result = result + y / s
		elif result - ed > 1e-06 / a[0][i]:
			result = result + y / s
		else:
			result = ed + y / s
	print(result)


t = int(input())
min1 = 1e-06
for _ in range(t):
	(n, s, y) = map(int, input().split())
	V = list(map(int, input().split()))
	D = list(map(int, input().split()))
	Dir = [2 * D[i] - 1 for i in range(n)]
	P = list(map(int, input().split()))
	C = list(map(int, input().split()))
	(time, dt) = (0, round(y / s, 6))
	for i in range(n):
		(tc1, tc2) = (-P[i] * Dir[i] / V[i], (C[i] - P[i] * Dir[i]) / V[i])
		if tc1 - dt < time + min1 < tc2:
			time = tc2 + dt
		else:
			time += dt
	print('%.6f' % round(time, 6))


import sys
input = sys.stdin.readline
t = int(input())
eps = 1e-06
for _ in range(t):
	(n, s, y) = map(int, input().split())
	V = [int(x) for x in input().split()]
	D = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	for i in range(n):
		if D[i] == 0:
			V[i] *= -1
		else:
			C[i] *= -1
	ct = y / s
	t = 0
	for i in range(n):
		t1 = -P[i] / V[i]
		t2 = -(P[i] + C[i]) / V[i]
		if t2 + eps >= t and t + ct >= t1 - eps:
			t = t2 + ct + eps
		else:
			t = t + ct
	print(t)


import sys
import math
mod = 1000000007
mtime = 10 ** (-6)

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(n, s, y) = map(int, sys.stdin.readline().split(' '))
	v = list(map(int, sys.stdin.readline().split(' ')))
	d = list(map(int, sys.stdin.readline().split(' ')))
	p = list(map(int, sys.stdin.readline().split(' ')))
	c = list(map(int, sys.stdin.readline().split(' ')))
	time = 0
	fd = y / s
	for i in range(n):
		if d[i] == 0:
			pos = p[i] - v[i] * time
			if c[i] + pos < 0:
				time += fd
			else:
				time += fd
				if pos < 0:
					time += (c[i] + pos) / v[i]
				elif pos / v[i] <= fd + mtime:
					time += (c[i] + pos) / v[i]
		else:
			pos = p[i] + v[i] * time
			if pos - c[i] > 0:
				time += fd
			else:
				time += fd
				if pos > 0:
					time += (c[i] - pos) / v[i]
				elif abs(pos / v[i]) <= fd + mtime:
					time += (c[i] - pos) / v[i]
	print(time)


for i in range(int(input())):
	(n, s, y) = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	t1 = y / s
	tsfr = 0
	for j in range(n):
		add = 0
		if d[j] == 0:
			if p[j] - tsfr * v[j] > pow(10, -6) and (p[j] - tsfr * v[j] - pow(10, -6)) / v[j] < t1:
				add += (p[j] - tsfr * v[j] + c[j]) / v[j]
			elif p[j] - tsfr * v[j] <= pow(10, -6) and p[j] - tsfr * v[j] > 0:
				add += (p[j] - tsfr * v[j] + c[j]) / v[j]
			elif p[j] - tsfr * v[j] <= 0 and p[j] - tsfr * v[j] + c[j] > 0:
				add += (p[j] - tsfr * v[j] + c[j]) / v[j]
		elif p[j] + tsfr * v[j] < -pow(10, -6) and (abs(p[j] + tsfr * v[j]) - pow(10, -6)) / v[j] < t1:
			add += (abs(p[j] + tsfr * v[j]) + c[j]) / v[j]
		elif p[j] + tsfr * v[j] >= -pow(10, -6) and p[j] + tsfr * v[j] < 0:
			add += abs(p[j] + tsfr * v[j] - c[j]) / v[j]
		elif p[j] + tsfr * v[j] >= 0 and p[j] + tsfr * v[j] - c[j] < 0:
			add += abs(p[j] + tsfr * v[j] - c[j]) / v[j]
		tsfr = tsfr + t1 + add
	print(tsfr)


for t in range(0, int(input())):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	time = 0.0
	for i in range(0, n):
		x = v[i] * time
		if d[i] == 0:
			p[i] = p[i] - x
		else:
			p[i] = p[i] + x
		time = time + y / s
		if d[i] == 0:
			if p[i] + c[i] > 0:
				dist = v[i] * (y / s)
				temp = p[i] - dist
				if temp <= 10 ** (-6):
					time = time + (p[i] + c[i]) / v[i]
		elif p[i] - c[i] < 0:
			dist = v[i] * (y / s)
			temp = p[i] + dist
			if temp >= -10 ** (-6):
				time = time + -(p[i] - c[i]) / v[i]
	print(time)


T = int(input())
for a in range(T):
	inp = list(map(int, input().split()))
	N = inp[0]
	S = inp[1]
	Y = inp[2]
	velocity = list(map(int, input().split()))
	direction = list(map(int, input().split()))
	position = list(map(int, input().split()))
	length = list(map(int, input().split()))
	cross = Y / S
	time = 0
	for i in range(N):
		if direction[i] == 1:
			front = position[i] + time * velocity[i]
			back = front - length[i]
			if back >= 0:
				time += cross
			elif front <= 0:
				if (-1 * front - 10 ** (-6)) / velocity[i] > cross:
					time += cross
				else:
					time += cross + -1 * back / velocity[i]
			elif front >= 0 and back <= 0:
				time += -1 * back / velocity[i] + cross
		else:
			front = position[i] - time * velocity[i]
			back = front + length[i]
			if back <= 0:
				time += cross
			elif front >= 0:
				if (front - 10 ** (-6)) / velocity[i] > cross:
					time += cross
				else:
					time += cross + back / velocity[i]
			elif front <= 0 and back >= 0:
				time += back / velocity[i] + cross
	print(time)


test = int(input())
for i in range(test):
	(N, S, Y) = map(int, input().split())
	speedlist = list(map(int, input().split()))
	dirlist = list(map(int, input().split()))
	poslist = list(map(int, input().split()))
	lengthlist = list(map(int, input().split()))
	totaltime = 0
	time_required = Y / S
	for i in range(N):
		if dirlist[i] == 0:
			arr_time = poslist[i] / speedlist[i]
		else:
			arr_time = poslist[i] / speedlist[i] * -1
		dep_time = arr_time + lengthlist[i] / speedlist[i]
		wait_time = 0
		if arr_time >= 0 and totaltime + time_required >= arr_time:
			wait_time = dep_time - totaltime + pow(10, -6)
			if wait_time < 0:
				wait_time = 0
		totaltime += time_required + wait_time
	print(totaltime)


t = int(input())
while t:
	t -= 1
	(n, s, y) = map(int, input().split())
	lane_time = y / s
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ts = 0
	for i in range(n):
		if d[i] == 1:
			add_dist = v[i] * ts
			pos = p[i] - c[i] + add_dist + 1e-06
			dist = abs(pos)
			if pos >= 0:
				ts += lane_time
			elif pos + c[i] <= 0:
				dist1 = abs(pos + c[i])
				if dist1 / v[i] <= lane_time:
					time_taken = dist / v[i]
					ts += lane_time + time_taken
				else:
					ts += lane_time
			else:
				time_taken = dist / v[i]
				ts += lane_time + time_taken
		else:
			add_dist = v[i] * ts
			pos = p[i] + c[i] - add_dist - 1e-06
			dist = abs(pos)
			if pos <= 0:
				ts += lane_time
			elif pos - c[i] >= 0:
				dist1 = abs(pos - c[i])
				if dist1 / v[i] <= lane_time:
					time_taken = dist / v[i]
					ts += lane_time + time_taken
				else:
					ts += lane_time
			else:
				time_taken = dist / v[i]
				ts += lane_time + time_taken
	print('{:.6f}'.format(round(ts, 6)))


t = int(input())
while t:
	(n, s, y) = map(int, input().split())
	V = list(map(float, input().split()))
	D = list(map(int, input().split()))
	P = list(map(float, input().split()))
	C = list(map(float, input().split()))
	for i in range(n):
		if D[i] == 0:
			D[i] = -1
	start = []
	end = []
	for i in range(n):
		if D[i] == -1:
			start.append(-(P[i] - 1e-06) / (V[i] * D[i]))
			end.append(-(P[i] + C[i] + 1e-06) / (V[i] * D[i]))
		elif D[i] == 1:
			start.append(-(P[i] + 1e-06) / (V[i] * D[i]))
			end.append(-(P[i] - C[i] - 1e-06) / (V[i] * D[i]))
	time = float(0)
	for i in range(n):
		crosstime = time + float(y) / float(s)
		if time >= start[i] and time <= end[i] or (crosstime >= start[i] and crosstime <= end[i]) or (start[i] >= time and start[i] <= crosstime) or (end[i] >= time and end[i] <= crosstime):
			time = end[i] + float(y) / float(s)
		else:
			time = crosstime
	time = format(time, '.6f')
	print(time)
	t = t - 1


for i in range(int(input())):
	(n, s, width) = list(map(int, input().split()))
	time = 0
	v_sp = list(map(int, input().split()))
	d = list(map(int, input().split()))
	for t in range(n):
		if d[t] == 0:
			d[t] = -1
	icoor = list(map(int, input().split()))
	lenc = list(map(int, input().split()))
	for o in range(n):
		ncoor = icoor[o] + d[o] * time * v_sp[o]
		if d[o] == -1:
			if ncoor >= -lenc[o] - 1e-06 and ncoor <= width * v_sp[o] / s + 1e-06:
				time += (lenc[o] + ncoor + 1e-06) / v_sp[o]
		elif ncoor <= lenc[o] + 1e-06 and ncoor >= -width * v_sp[o] / s - 1e-06:
			time += (lenc[o] - ncoor + 1e-06) / v_sp[o]
		time += width / s
	print(time)


moe = 10 ** (-6)
for t in range(int(input())):
	(n, s, y) = [int(i) for i in input().split()]
	v = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	time = 0
	ttc = y / s
	for i in range(n):
		if d[i] == 0:
			d[i] = -1
		x1 = -1 * p[i] / (v[i] * d[i])
		x2 = -1 * (p[i] - c[i] * d[i]) / (v[i] * d[i])
		if time > x2 + moe or time + ttc < x1 - moe:
			time += ttc
		else:
			time = x2 + moe + ttc
	print(time)


def fun(index, time):
	for i in range(index, n):
		dep_time[i] -= time
		arr_time[i] -= time
for _ in range(int(input())):
	(n, s, y) = map(int, input().split())
	velocity = list(map(int, input().split()))
	direction = list(map(int, input().split()))
	position = list(map(int, input().split()))
	length = list(map(int, input().split()))
	chef_time = y / s
	x = 1e-06
	arr_time = []
	dep_time = []
	total_time = 0
	for car in range(n):
		if direction[car]:
			if position[car] + x >= 0:
				arr_time.append(0)
			else:
				temp = abs(position[car] + x) / velocity[car]
				arr_time.append(temp)
		elif position[car] - x <= 0:
			arr_time.append(0)
		else:
			temp = abs(position[car] - x) / velocity[car]
			arr_time.append(temp)
	for car in range(n):
		if direction[car]:
			if position[car] - length[car] + x >= 0:
				dep_time.append(0)
			else:
				temp = abs(position[car] - length[car] + x) / velocity[car]
				dep_time.append(temp)
		elif position[car] + length[car] - x <= 0:
			dep.time.append(0)
		else:
			temp = abs(position[car] + length[car] - x) / velocity[car]
			dep_time.append(temp)
	for car in range(n):
		if arr_time[car] <= 0 and dep_time[car] <= 0:
			total_time += chef_time
			fun(car + 1, chef_time)
		elif arr_time[car] <= 0:
			total_time += dep_time[car] + chef_time
			fun(car + 1, dep_time[car] + chef_time)
		elif chef_time < arr_time[car]:
			total_time += chef_time
			fun(car + 1, chef_time)
		elif chef_time > arr_time[car]:
			total_time += dep_time[car] + chef_time
			fun(car + 1, dep_time[car] + chef_time)
	print(total_time)


import sys

def collision(carvelocity, carlength, carstartpos, cheftime, crosstime):
	margin = 10 ** (-6)
	p_front_start = carstartpos + carvelocity * crosstime
	if carvelocity < 0:
		p_back_start = p_front_start + carlength + margin
	else:
		p_back_start = p_front_start - carlength - margin
	p_front_end = p_front_start + cheftime * carvelocity
	p_back_end = p_back_start + cheftime * carvelocity
	if p_back_start * p_front_end > 0:
		return cheftime
	else:
		waittime = abs(p_back_start / carvelocity)
		return waittime + cheftime
t = int(sys.stdin.readline())
for case in range(t):
	(n, s, y) = [int(i) for i in sys.stdin.readline().strip().split()]
	v = [int(i) for i in sys.stdin.readline().strip().split()]
	d = [int(i) for i in sys.stdin.readline().strip().split()]
	p = [int(i) for i in sys.stdin.readline().strip().split()]
	c = [int(i) for i in sys.stdin.readline().strip().split()]
	crosstime = 0
	cheftime = y / s
	for lane in range(n):
		carlength = c[lane]
		carstartpos = p[lane]
		carvelocity = v[lane]
		if d[lane] == 0:
			carvelocity *= -1
		crosstime += collision(carvelocity, carlength, carstartpos, cheftime, crosstime)
	print(format(crosstime, '.6f'))


t = int(input(''))
for i in range(t):
	(n, s, w) = list(map(int, input().split()))
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	tym = w / s
	t1 = 0
	for i in range(n):
		if d[i] == 1 and p[i] - c[i] < 1e-06 or (d[i] == 0 and p[i] + c[i] > 1e-06):
			if d[i] == 1:
				p[i] = p[i] + v[i] * t1
			if d[i] == 0:
				p[i] = p[i] - v[i] * t1
		if d[i] == 1 and p[i] - c[i] >= 1e-06 or (d[i] == 0 and p[i] + c[i] <= 1e-06):
			t1 += tym
			continue
		if d[i] == 1:
			l = p[i] - c[i]
			if p[i] < 0:
				t2 = -1 * p[i] / v[i]
				if tym - t2 < -1e-06:
					t1 += tym
				else:
					t2 = -1 * l / v[i]
					t1 = t1 + t2 + tym
			if p[i] >= 0:
				t2 = (c[i] - p[i]) / v[i]
				t1 = tym + t2 + t1
		if d[i] == 0:
			l = p[i] + c[i]
			if p[i] > 0:
				t2 = p[i] / v[i]
				if tym - t2 < -1e-06:
					t1 += tym
				else:
					t2 = l / v[i]
					t1 = t1 + t2 + tym
			if p[i] <= 0:
				t2 = (c[i] + p[i]) / v[i]
				t1 = tym + t2 + t1
	print('{0:.6f}'.format(t1))


def time1(n, s, y, v, d, p, c, i):
	tr = y / s
	time = 0
	if d[i] == 0:
		if p[i] >= 0:
			tc = p[i] / v[i]
			if tc - 1e-06 > tr:
				time = tr
			else:
				time = tr + (p[i] + c[i]) / v[i]
		elif p[i] + 1e-06 > -1 * c[i]:
			dist = c[i] + p[i]
			time = tr + dist / v[i]
		else:
			time = tr
	elif p[i] <= 0:
		tc = -1 * p[i] / v[i]
		if tc - 1e-06 > tr:
			time = tr
		else:
			time = tr + (-1 * p[i] + c[i]) / v[i]
	elif p[i] + 1e-06 <= c[i]:
		dist = c[i] - p[i]
		time = tr + dist / v[i]
	else:
		time = tr
	return time
t = int(input())
for iq in range(0, t):
	(n, s, y) = map(int, input().strip().split())
	v = list(map(int, input().strip().split()))
	d = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	c = list(map(int, input().strip().split()))
	total = 0
	for ijk in range(0, n):
		q = time1(n, s, y, v, d, p, c, ijk)
		total += q
		for j in range(ijk + 1, n):
			if d[j] == 0:
				p[j] -= q * v[j]
			else:
				p[j] += q * v[j]
	print(total)


for t in range(int(input())):
	(n, s, y) = map(int, input().split())
	v = list(map(int, input().split()))
	d = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = list(map(int, input().split()))
	chef_time = y / s
	count = 0
	for i in range(n):
		a = count * v[i]
		if d[i] == 1:
			p[i] += a
			head = p[i]
			tail = p[i] - c[i]
			if tail >= 0:
				count += chef_time
			elif head < 0:
				new_temp = abs(p[i]) / v[i]
				if new_temp - chef_time > 1e-06:
					count += chef_time
				else:
					count += chef_time + new_temp + c[i] / v[i]
			elif head > 0 and tail < 0:
				count += abs(tail) / v[i] + chef_time
			elif head == 0:
				count += c[i] / v[i] + chef_time
		else:
			p[i] -= a
			head = p[i]
			tail = p[i] + c[i]
			if head > 0:
				new_temp = abs(p[i]) / v[i]
				if new_temp - chef_time > 1e-06:
					count += chef_time
				else:
					count += chef_time + new_temp + c[i] / v[i]
			elif head < 0 and tail > 0:
				count += abs(tail) / v[i] + chef_time
			elif tail <= 0:
				count += chef_time
			elif head == 0:
				count += c[i] / v[i] + chef_time
	print(count)


import math
t = int(input())
a = pow(10, -6)
for _ in range(t):
	chef = 0
	wait = 0
	che = []
	(n, s, y) = [int(x) for x in input().split()]
	v = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	d = [-1 if x == 0 else x for x in d]
	p = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	t = y / s
	for i in range(n):
		f = sum(che)
		posi_t1 = p[i] + v[i] * f * d[i]
		posi_t2 = posi_t1 + v[i] * t * d[i]
		if d[i] == 1:
			if posi_t1 < -a and posi_t2 <= -a:
				che.append(t)
			elif posi_t1 - c[i] >= a:
				che.append(t)
			else:
				wait = (abs(p[i]) + c[i]) / v[i] - sum(che)
				che.append(t + wait)
		elif posi_t1 > a and posi_t2 >= a:
			che.append(t)
		elif posi_t1 + c[i] <= -a:
			che.append(t)
		else:
			wait = (abs(p[i]) + c[i]) / v[i] - f
			che.append(t + wait)
	print(sum(che))