from collections import deque
from itertools import pairwise

INF = 1 << 60
N, KA, KB = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
B = list(map(lambda x: int(x)-1, input().split()))


def calc_warp_dists(warps: list[int]) -> list[int]:
    dists = [INF] * N
    q = deque()
    for wi in warps:
        q.append(wi)
        dists[wi] = 0

    while q:
        wi = q.popleft()
        if wi > 0 and dists[wi-1] > dists[wi] + 1:
            dists[wi-1] = dists[wi] + 1
            q.append(wi-1)

        if wi+1 < N and dists[wi+1] > dists[wi] + 1:
            dists[wi+1] = dists[wi] + 1
            q.append(wi+1)

    return dists


a_warp_dists = calc_warp_dists(A)
b_warp_dists = calc_warp_dists(B)

ab_warp_dist = INF  # ワープ A, B 間の最短距離
ws = [(a, 0) for a in A] + [(b, 1) for b in B]
for (x, xt), (y, yt) in pairwise(sorted(ws)):
    if xt != yt:
        ab_warp_dist = min(ab_warp_dist, y - x)


def solve(s: int, t: int) -> int:
    # S -> T
    x1 = t - s
    # S -> A -> T
    x2 = a_warp_dists[s] + a_warp_dists[t]
    # S -> B -> T
    x3 = b_warp_dists[s] + b_warp_dists[t]
    # S -> A -> B -> T
    x4 = a_warp_dists[s] + ab_warp_dist + b_warp_dists[t]
    # S -> B -> A -> T
    x5 = b_warp_dists[s] + ab_warp_dist + a_warp_dists[t]

    return min(x1, x2, x3, x4, x5)


Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())

    res = solve(s, t)
    print(res)