A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]

T = [int(input()) for _ in range(B)]

from bisect import bisect_left

for _ in range(Q):
    ans = 10**12
    x = int(input())
    idxs = bisect_left(S,x)
    idxt = bisect_left(T,x)

    if idxs < A and idxt < B:
        ans = min(ans, max(S[idxs],T[idxt])-x)
    if 0 <= idxs-1 and 0 <= idxt-1:
        ans = min(ans, x-min(S[idxs-1],T[idxt-1]))
    if idxs < A and 0 <= idxt-1:
        ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1]))
    if idxt < B and 0 <= idxs-1:
        ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1]))
    print(ans) A,B,Q = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [int(input()) for _ in range(A)] S [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [int(input()) for _ in range(B)] T [int(input()) for _ in range(B)] from bisect import bisect_left for _ in range(Q):
    ans = 10**12
    x = int(input())
    idxs = bisect_left(S,x)
    idxt = bisect_left(T,x)

    if idxs < A and idxt < B:
        ans = min(ans, max(S[idxs],T[idxt])-x)
    if 0 <= idxs-1 and 0 <= idxt-1:
        ans = min(ans, x-min(S[idxs-1],T[idxt-1]))
    if idxs < A and 0 <= idxt-1:
        ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1]))
    if idxt < B and 0 <= idxs-1:
        ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1]))
    print(ans) _ range(Q) range Q ans = 10**12 ans 10**12 10 12 x = int(input()) x int(input()) int input() input idxs = bisect_left(S,x) idxs bisect_left(S,x) bisect_left S x idxt = bisect_left(T,x) idxt bisect_left(T,x) bisect_left T x if idxs < A and idxt < B:
        ans = min(ans, max(S[idxs],T[idxt])-x)
     idxs < A and idxt < B idxs < A idxs A idxt < B idxt B ans = min(ans, max(S[idxs],T[idxt])-x) ans min(ans, max(S[idxs],T[idxt])-x) min ans max(S[idxs],T[idxt])-x max(S[idxs],T[idxt]) max S[idxs] S idxs T[idxt] T idxt x if 0 <= idxs-1 and 0 <= idxt-1:
        ans = min(ans, x-min(S[idxs-1],T[idxt-1]))
     0 <= idxs-1 and 0 <= idxt-1 0 <= idxs-1 0 idxs-1 idxs 1 0 <= idxt-1 0 idxt-1 idxt 1 ans = min(ans, x-min(S[idxs-1],T[idxt-1])) ans min(ans, x-min(S[idxs-1],T[idxt-1])) min ans x-min(S[idxs-1],T[idxt-1]) x min(S[idxs-1],T[idxt-1]) min S[idxs-1] S idxs-1 idxs 1 T[idxt-1] T idxt-1 idxt 1 if idxs < A and 0 <= idxt-1:
        ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1]))
     idxs < A and 0 <= idxt-1 idxs < A idxs A 0 <= idxt-1 0 idxt-1 idxt 1 ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1])) ans min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1])) min ans S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1]) S[idxs]-T[idxt-1] S[idxs] S idxs T[idxt-1] T idxt-1 idxt 1 min(S[idxs]-x, x-T[idxt-1]) min S[idxs]-x S[idxs] S idxs x x-T[idxt-1] x T[idxt-1] T idxt-1 idxt 1 if idxt < B and 0 <= idxs-1:
        ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1]))
     idxt < B and 0 <= idxs-1 idxt < B idxt B 0 <= idxs-1 0 idxs-1 idxs 1 ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1])) ans min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1])) min ans T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1]) T[idxt]-S[idxs-1] T[idxt] T idxt S[idxs-1] S idxs-1 idxs 1 min(T[idxt]-x, x-S[idxs-1]) min T[idxt]-x T[idxt] T idxt x x-S[idxs-1] x S[idxs-1] S idxs-1 idxs 1 print(ans) print ans Q = map(int,input().split()) map(int,input().split()) Q A,B,Q = map(int,input().split()) map(int,input().split()) A ans = min(ans, x-min(S[idxs-1],T[idxt-1])) min(ans, x-min(S[idxs-1],T[idxt-1])) ans ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1])) min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1])) ans x = int(input()) int(input()) x idxs = bisect_left(S,x) bisect_left(S,x) idxs B,Q = map(int,input().split()) map(int,input().split()) B idxt = bisect_left(T,x) bisect_left(T,x) idxt S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1])) min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1])) ans ans = 10**12 10**12 ans ans = min(ans, max(S[idxs],T[idxt])-x) min(ans, max(S[idxs],T[idxt])-x) ans T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T
A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]

T = [int(input()) for _ in range(B)]

from bisect import bisect_left

for _ in range(Q):
    ans = 10**12
    x = int(input())
    idxs = bisect_left(S,x)
    idxt = bisect_left(T,x)

    if idxs < A and idxt < B:
        ans = min(ans, max(S[idxs],T[idxt])-x)
    if 0 <= idxs-1 and 0 <= idxt-1:
        ans = min(ans, x-min(S[idxs-1],T[idxt-1]))
    if idxs < A and 0 <= idxt-1:
        ans = min(ans, S[idxs]-T[idxt-1] + min(S[idxs]-x, x-T[idxt-1]))
    if idxt < B and 0 <= idxs-1:
        ans = min(ans, T[idxt]-S[idxs-1] + min(T[idxt]-x, x-S[idxs-1]))
    print(ans)
