""" https://yukicoder.me/problems/no/3072 """ import heapq def Dijkstra(lis,start): ret = [float("inf")] * len(lis) ret[start] = 0 end_flag = [False] * len(lis) end_num = 0 q = [(0,start)] while len(q) > 0: ncost,now = heapq.heappop(q) if end_flag[now]: continue end_flag[now] = True end_num += 1 if end_num == len(lis): break for nex,ecost in lis[now]: if ret[nex] > ncost + ecost: ret[nex] = ncost + ecost heapq.heappush(q , (ret[nex] , nex)) return ret N,Ka,Kb = map(int,input().split()) av = list(map(int,input().split())) bv = list(map(int,input().split())) lis = [ [] for i in range(N+2) ] for i in range(N-1): lis[i].append( (i+1,1) ) lis[i+1].append( (i,1) ) for v in av: lis[v-1].append( (N,0) ) lis[N].append( (v-1,0) ) for v in bv: lis[v-1].append( (N+1,0) ) lis[N+1].append( (v-1,0) ) da = Dijkstra(lis,N) db = Dijkstra(lis,N+1) Q = int(input()) for _ in range(Q): s,t = map(int,input().split()) s -= 1 t -= 1 ans = min( abs(s-t) , da[s]+da[t] , db[s]+db[t] , da[s]+da[N+1]+db[t] , da[t]+da[N+1]+db[s] ) print (ans)