# D - Lazy Faith

import bisect
INF = 10**18
A, B, Q = map(int, input().split())
S = [0]*A
T = [0]*B
X = [0]*Q
for i in range(A):
    S[i] = int(input())

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

for i in range(Q):
    X[i] = int(input())

for x in X:
    #print(x)
    idxS = bisect.bisect_left(S, x)
    #print('idxS', idxS)
    if idxS==0:
        leftS = INF
        rightS = S[idxS] - x
    elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
    else:
        leftS = x - S[idxS-1]
        rightS = S[idxS] - x
    #print(leftS, rightS)
    idxT = bisect.bisect_left(T, x)
    if idxT==0:
        leftT = INF
        rightT = T[idxT] -x
    elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
    else:
        leftT = x - T[idxT-1]
        rightT = T[idxT] - x
    #print(leftT, rightT)
    ans = max(leftS, leftT)
    ans = min(ans, max(rightS, rightT))
    ans = min(ans, leftS * 2 + rightT)
    ans = min(ans, leftT * 2 + rightS)
    ans = min(ans, leftS + rightT * 2)
    ans = min(ans, leftT + rightS * 2)
    print(ans) import bisect bisect INF = 10**18 INF 10**18 10 18 A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q S = [0]*A S [0]*A [0] 0 A T = [0]*B T [0]*B [0] 0 B X = [0]*Q X [0]*Q [0] 0 Q for i in range(A):
    S[i] = int(input()) i range(A) range A S[i] = int(input()) S[i] S i int(input()) int input() input for i in range(B):
    T[i] = int(input()) i range(B) range B T[i] = int(input()) T[i] T i int(input()) int input() input for i in range(Q):
    X[i] = int(input()) i range(Q) range Q X[i] = int(input()) X[i] X i int(input()) int input() input for x in X:
    #print(x)
    idxS = bisect.bisect_left(S, x)
    #print('idxS', idxS)
    if idxS==0:
        leftS = INF
        rightS = S[idxS] - x
    elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
    else:
        leftS = x - S[idxS-1]
        rightS = S[idxS] - x
    #print(leftS, rightS)
    idxT = bisect.bisect_left(T, x)
    if idxT==0:
        leftT = INF
        rightT = T[idxT] -x
    elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
    else:
        leftT = x - T[idxT-1]
        rightT = T[idxT] - x
    #print(leftT, rightT)
    ans = max(leftS, leftT)
    ans = min(ans, max(rightS, rightT))
    ans = min(ans, leftS * 2 + rightT)
    ans = min(ans, leftT * 2 + rightS)
    ans = min(ans, leftS + rightT * 2)
    ans = min(ans, leftT + rightS * 2)
    print(ans) x X idxS = bisect.bisect_left(S, x) idxS bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x if idxS==0:
        leftS = INF
        rightS = S[idxS] - x
    elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
    else:
        leftS = x - S[idxS-1]
        rightS = S[idxS] - x
    #print(leftS, rightS)
     idxS==0 idxS 0 leftS = INF leftS INF rightS = S[idxS] - x rightS S[idxS] - x S[idxS] S idxS x elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
     idxS==A idxS A leftS = x - S[idxS-1] leftS x - S[idxS-1] x S[idxS-1] S idxS-1 idxS 1 rightS = INF rightS INF leftS = x - S[idxS-1] leftS x - S[idxS-1] x S[idxS-1] S idxS-1 idxS 1 rightS = S[idxS] - x rightS S[idxS] - x S[idxS] S idxS x idxT = bisect.bisect_left(T, x) idxT bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x if idxT==0:
        leftT = INF
        rightT = T[idxT] -x
    elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
    else:
        leftT = x - T[idxT-1]
        rightT = T[idxT] - x
    #print(leftT, rightT)
     idxT==0 idxT 0 leftT = INF leftT INF rightT = T[idxT] -x rightT T[idxT] -x T[idxT] T idxT x elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
     idxT==B idxT B leftT = x - T[idxT-1] leftT x - T[idxT-1] x T[idxT-1] T idxT-1 idxT 1 rightT = INF rightT INF leftT = x - T[idxT-1] leftT x - T[idxT-1] x T[idxT-1] T idxT-1 idxT 1 rightT = T[idxT] - x rightT T[idxT] - x T[idxT] T idxT x ans = max(leftS, leftT) ans max(leftS, leftT) max leftS leftT ans = min(ans, max(rightS, rightT)) ans min(ans, max(rightS, rightT)) min ans max(rightS, rightT) max rightS rightT ans = min(ans, leftS * 2 + rightT) ans min(ans, leftS * 2 + rightT) min ans leftS * 2 + rightT leftS * 2 leftS 2 rightT ans = min(ans, leftT * 2 + rightS) ans min(ans, leftT * 2 + rightS) min ans leftT * 2 + rightS leftT * 2 leftT 2 rightS ans = min(ans, leftS + rightT * 2) ans min(ans, leftS + rightT * 2) min ans leftS + rightT * 2 leftS rightT * 2 rightT 2 ans = min(ans, leftT + rightS * 2) ans min(ans, leftT + rightS * 2) min ans leftT + rightS * 2 leftT rightS * 2 rightS 2 print(ans) print ans idxT = bisect.bisect_left(T, x) bisect.bisect_left(T, x) idxT B, Q = map(int, input().split()) map(int, input().split()) B X = [0]*Q [0]*Q X rightS = S[idxS] - x S[idxS] - x rightS rightT = T[idxT] - x T[idxT] - x rightT leftT = x - T[idxT-1] x - T[idxT-1] leftT leftT = x - T[idxT-1] x - T[idxT-1] leftT rightT = INF INF rightT ans = min(ans, leftT * 2 + rightS) min(ans, leftT * 2 + rightS) ans leftS = INF INF leftS leftS = x - S[idxS-1] x - S[idxS-1] leftS ans = min(ans, leftS * 2 + rightT) min(ans, leftS * 2 + rightT) ans INF = 10**18 10**18 INF rightT = T[idxT] -x T[idxT] -x rightT ans = min(ans, max(rightS, rightT)) min(ans, max(rightS, rightT)) ans rightS = INF INF rightS ans = min(ans, leftS + rightT * 2) min(ans, leftS + rightT * 2) ans ans = min(ans, leftT + rightS * 2) min(ans, leftT + rightS * 2) ans S = [0]*A [0]*A S idxS = bisect.bisect_left(S, x) bisect.bisect_left(S, x) idxS leftS = x - S[idxS-1] x - S[idxS-1] leftS A, B, Q = map(int, input().split()) map(int, input().split()) A Q = map(int, input().split()) map(int, input().split()) Q leftT = INF INF leftT ans = max(leftS, leftT) max(leftS, leftT) ans rightS = S[idxS] - x S[idxS] - x rightS T = [0]*B [0]*B T
# D - Lazy Faith

import bisect
INF = 10**18
A, B, Q = map(int, input().split())
S = [0]*A
T = [0]*B
X = [0]*Q
for i in range(A):
    S[i] = int(input())

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

for i in range(Q):
    X[i] = int(input())

for x in X:
    #print(x)
    idxS = bisect.bisect_left(S, x)
    #print('idxS', idxS)
    if idxS==0:
        leftS = INF
        rightS = S[idxS] - x
    elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
    else:
        leftS = x - S[idxS-1]
        rightS = S[idxS] - x
    #print(leftS, rightS)
    idxT = bisect.bisect_left(T, x)
    if idxT==0:
        leftT = INF
        rightT = T[idxT] -x
    elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
    else:
        leftT = x - T[idxT-1]
        rightT = T[idxT] - x
    #print(leftT, rightT)
    ans = max(leftS, leftT)
    ans = min(ans, max(rightS, rightT))
    ans = min(ans, leftS * 2 + rightT)
    ans = min(ans, leftT * 2 + rightS)
    ans = min(ans, leftS + rightT * 2)
    ans = min(ans, leftT + rightS * 2)
    print(ans)