#P1873F. Money Trees
Money Trees
No submission language available for this problem.
Description
Luca is in front of a row of trees. The -th tree has fruit and height .
He wants to choose a contiguous subarray of the array such that for each (), is divisible by . He will collect all the fruit from each of the trees in the subarray (that is, he will collect fruits). However, if he collects more than fruits in total, he will get caught.
What is the maximum length of a subarray Luca can choose so he doesn't get caught?
is divisible by if the ratio is an integer.
The first line contains a single integer () — the number of test cases.
The first of each test case line contains two space-separated integers and (; ) — the number of trees and the maximum amount of fruits Luca can collect without getting caught.
The second line of each test case contains space-separated integers () — the number of fruits in the -th tree.
The third line of each test case contains space-separated integers () — the height of the -th tree.
The sum of over all test cases does not exceed .
For each test case output a single integer, the length of the maximum length contiguous subarray satisfying the conditions, or if there is no such subarray.
Input
The first line contains a single integer () — the number of test cases.
The first of each test case line contains two space-separated integers and (; ) — the number of trees and the maximum amount of fruits Luca can collect without getting caught.
The second line of each test case contains space-separated integers () — the number of fruits in the -th tree.
The third line of each test case contains space-separated integers () — the height of the -th tree.
The sum of over all test cases does not exceed .
Output
For each test case output a single integer, the length of the maximum length contiguous subarray satisfying the conditions, or if there is no such subarray.
Note
In the first test case, Luca can select the subarray with and .
In the second test case, Luca can select the subarray with and .
In the third test case, Luca can select the subarray with and .