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

from math import ceil
import sys
n,M,cl,ce,v = map(int, raw_input().split())
strs = map(int, raw_input().split())
elvs = map(int, raw_input().split())

def try_str(r1,c1,r2,c2):
    a = binSearch(strs,c1)
    b = a+1
    opts = []
    if a>=0: opts.append(a)
    if b<len(strs): opts.append(b)
    res = []
    for pos in opts:
        t = abs(c1-strs[pos])
        t += abs(r2-r1)
        t += abs(strs[pos]-c2)
        res.append(t)
    while len(res)<2: res.append(sys.maxint)
    return res

def try_elv(r1,c1,r2,c2):
    a = binSearch(elvs,c1)
    b = a+1
    # make elevators
    opts = []
    if a>=0: opts.append(a)
    if b<len(elvs):
        opts.append(b)
    # try elevators
    res = []
    for pos in opts:
        t = abs(c1-elvs[pos])
        t += abs(int(ceil(abs(r2-r1)/float(v))))
        t += abs(elvs[pos]-c2)
        res.append(t)
    while len(res)<2: res.append(sys.maxint)
    return res  


def binSearch(arr,x, l=0, r=None) :
    if r==None: r = len(arr)
    if l >= r-1 : return l
    mid = (l+r) / 2
    if x < arr[mid] :
        return binSearch(arr,x,l,mid)
    elif x > arr[mid] :
        return binSearch(arr,x,mid,r)
    return mid

'''
def binSearch(a,val):
    s,e=0,len(a)-1
    while s<=e:
        m = (s+e)/2
        if a[m]<val: s = m+1
        elif a[m]>val: e = m-1
        else: return m
    # Get first left
    s = min(s,len(a)-1)
    while s>=0 and a[s]>val: s -= 1
    return s    
'''

Q = int(raw_input())
for q in xrange(Q):
    r1,c1,r2,c2 = map(int, raw_input().split())
    if c1==c2:
        print abs(r2-r1)
        continue
    if ce>0: o1,o2 = try_elv(r1,c1,r2,c2)
    else: o1,o2 = sys.maxint, sys.maxint
    if cl>0: o3,o4 = try_str(r1,c1,r2,c2)
    else: o3,o4 = sys.maxint, sys.maxint
    print min(o1,o2,o3,o4)
