import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
print(*ans,sep="\n") import bisect bisect A,B,Q = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q INF = float('inf') INF float('inf') float 'inf' int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [-INF]+[int(input()) for _ in range(A)]+[INF] S [-INF]+[int(input()) for _ in range(A)]+[INF] [-INF]+[int(input()) for _ in range(A)] [-INF] -INF INF [int(input()) for _ in range(A)] [INF] INF int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [-INF]+[int(input()) for _ in range(B)]+[INF] T [-INF]+[int(input()) for _ in range(B)]+[INF] [-INF]+[int(input()) for _ in range(B)] [-INF] -INF INF [int(input()) for _ in range(B)] [INF] INF ans = [] ans [] for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d) q range(Q) range Q x = int(input()) x int(input()) int input() input i = bisect.bisect_right(S,x) i bisect.bisect_right(S,x) bisect.bisect_right bisect bisect_right S x j = bisect.bisect_right(T,x) j bisect.bisect_right(T,x) bisect.bisect_right bisect bisect_right T x d = INF d INF for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
     s [S[i-1],S[i]] S[i-1] S i-1 i 1 S[i] S i for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
     t [T[j-1],T[j]] T[j-1] T j-1 j 1 T[j] T j d1 = abs(x-s) + abs(s-t) d1 abs(x-s) + abs(s-t) abs(x-s) abs x-s x s abs(s-t) abs s-t s t d2 = abs(x-t) + abs(s-t) d2 abs(x-t) + abs(s-t) abs(x-t) abs x-t x t abs(s-t) abs s-t s t d = min(d,d1,d2) d min(d,d1,d2) min d d1 d2 ans.append(d) ans.append ans append d print(*ans,sep="\n") print *ans ans sep="\n" sep "\n" d = INF INF d S = [-INF]+[int(input()) for _ in range(A)]+[INF] [-INF]+[int(input()) for _ in range(A)]+[INF] S i = bisect.bisect_right(S,x) bisect.bisect_right(S,x) i Q = map(int,input().split()) map(int,input().split()) Q B,Q = map(int,input().split()) map(int,input().split()) B j = bisect.bisect_right(T,x) bisect.bisect_right(T,x) j INF = float('inf') float('inf') INF T = [-INF]+[int(input()) for _ in range(B)]+[INF] [-INF]+[int(input()) for _ in range(B)]+[INF] T ans = [] [] ans d1 = abs(x-s) + abs(s-t) abs(x-s) + abs(s-t) d1 x = int(input()) int(input()) x d2 = abs(x-t) + abs(s-t) abs(x-t) + abs(s-t) d2 A,B,Q = map(int,input().split()) map(int,input().split()) A d = min(d,d1,d2) min(d,d1,d2) d
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
print(*ans,sep="\n")