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

#include <bits/stdc++.h>
int main() {
  int n, m, cl, ce, v, i, k, q;
  scanf("%d%d%d%d%d", &n, &m, &cl, &ce, &v);
  int j[cl + ce], l[cl + ce];
  for (i = 0; i < cl + ce; i++) {
    scanf("%d", &l[i]);
  }
  scanf("%d", &q);
  int x1[q], y1[q], x2[q], y2[q];
  for (i = 0; i < q; i++) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
  }
  if (cl > ce)
    n = cl;
  else
    n = ce;
  m = 999999999;
  for (i = 0; i < q; i++) {
    for (k = 0; k < n; k++) {
      if (k < cl) {
        j[k] = sqrt((y2[i] - l[k]) * (y2[i] - l[k])) +
               sqrt((l[k] - y1[i]) * (l[k] - y1[i])) +
               sqrt((x2[i] - x1[i]) * (x2[i] - x1[i]));
        if (m > j[k]) m = j[k];
      }
      if (k < ce) {
        j[k + cl] = sqrt((y2[i] - l[k + cl]) * (y2[i] - l[k + cl])) +
                    sqrt((l[k + cl] - y1[i]) * (l[k + cl] - y1[i])) +
                    (sqrt((x2[i] - x1[i]) * (x2[i] - x1[i])) / v);
        if ((int)sqrt((x2[i] - x1[i]) * (x2[i] - x1[i])) % v != 0) j[k + cl]++;
        if (m > j[k + cl]) m = j[k + cl];
      }
    }
    printf("%d\n", m);
  }
  return 0;
}
