Train in a Tunnel

Given car lengths and light states, find the minimum number of extra lights to turn on so that at every moment some lit car overlaps the tunnel.

Medium7ArrayTwo pointersGreedySliding windowNo attempts yetTime limit2sMemory limit256 MB

Problem

Peter is traveling by train. The train has nn cars, and the ii-th car is aia_i meters long. Assume there is no gap between cars.

Some of the cars have their light on and the rest have it off. The train is about to enter a tunnel of length hh meters. A moment is dark if every car that has a part of nonzero length inside the tunnel has its light off. A car that touches the tunnel entrance or exit at a single point only does not count as being inside the tunnel.

Peter wants no dark moment from the instant the front of the train enters the tunnel until the instant the rear of the train leaves it. The lights that are already on stay on. Find the smallest number of cars whose light Peter has to turn on.

Input

The first line contains the number of test cases tt (1t1001 \le t \le 100).

The first line of each test case contains the number of cars nn and the length of the tunnel hh (1n1051 \le n \le 10^5, 1h1091 \le h \le 10^9). The second line contains the car lengths a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9). The third line contains nn integers, where the ii-th value is 11 if the light of the ii-th car is on and 00 if it is off. The cars are given in the order they enter the tunnel.

The sum of nn over all test cases does not exceed 10610^6.

Output

For each test case, print on one line the smallest number of cars whose light must be turned on so that no dark moment occurs.