2 10 1 1 1
1
10
1
1 5 1 8
 4 4 1 0 1
1

1
1 2 1 4
 2 5 1 0 1
2

1
1 4 1 5
 10 10 1 8 4
10
2 3 4 5 6 7 8 9
10
1 1 3 1
2 1 7 1
1 1 9 1
7 1 4 1
10 1 7 1
2 1 7 1
3 1 2 1
5 1 2 1
10 1 5 1
6 1 9 1
 2 4 1 1 1
1
4
1
1 2 1 3
 2 2 0 1 1

1
1
1 2 2 2
 1000 1000 1 1 10
1
2
1
1 900 1 1000
 5 5 1 1 1
3
2
1
1 5 1 1
 2 4 1 1 1
1
2
1
2 3 2 4
 4 4 1 0 1
4

5
1 1 2 2
1 3 2 2
3 3 4 3
3 2 2 2
1 2 2 3

3
 2
 1
 3
4
4
3
3
4
3
3
4
3
 1
 3
 100
 4
 1
 6
4
3
5
4

import bisect
N,M,L,E,V = map(int,input().split())
sts = list(map(int,input().split()))
els = list(map(int,input().split()))

def solve(x1,y1,x2,y2):
    if x1 == x2:
        return abs(y1-y2)
    ans = N+M+9999
    if y1 > y2: y1,y2 = y2,y1
    if sts:
        i = bisect.bisect(sts,y1)
        if i == L:
            st = sts[-1]
            t = abs(st - y1) + abs(st - y2) + abs(x1 - x2)
            ans = min(ans, t)
        else:
            st = sts[i]
            t = abs(st - y1) + abs(st - y2) + abs(x1 - x2)
            ans = min(ans, t)
            if i < L-1:
                st = sts[i+1]
                t = abs(st - y1) + abs(st - y2) + abs(x1 - x2)
                ans = min(ans, t)
    if els:
        i = bisect.bisect(els,y1)
        if i == E:
            el = els[-1]
            t = abs(el - y1) + abs(el - y2) + (abs(x1-x2)-1)//V + 1
            ans = min(ans, t)
        else:
            el = els[i]
            t = abs(el - y1) + abs(el - y2) + (abs(x1-x2)-1)//V + 1
            ans = min(ans, t)
            if i < E-1:
                el = els[i+1]
                t = abs(el - y1) + abs(el - y2) + (abs(x1-x2)-1)//V + 1
                ans = min(ans, t)
    return ans

Q = int(input())
anss = []
for i in range(Q):
    anss.append(solve(*tuple(map(int,input().split()))))
print(*anss,sep='\n')
