def solve len ans for in range for in range print m1 max m2 max if abs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def solve(a, b, k):
n = len(a)
ans = 0
for i in range(n):
for j in range(i, n):
#print(i, j+1)
m1 = max(a[i:j+1])
m2 = max(b[i:j+1])
if abs(m1 - m2) <= k:
ans += 1
return ans
t = int(input())
for test_num in range(1, t + 1):
n1, k1 = map(int, input().split(' '))
c = map(int, input().split(' '))
d = map(int, input().split(' '))
ans1 = solve(list(c), list(d), k1)
print("Case #{}: {}".format(test_num,ans1))