import bisect

A,B,Q=map(int,input().split())
S=[-10**18]+[int(input()) for _ in range(A)]+[10**18]
T=[-10**18]+[int(input()) for _ in range(B)]+[10**18]

for i in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x)
    ans=float("inf")
    for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
    print(ans) import bisect bisect 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=[-10**18]+[int(input()) for _ in range(A)]+[10**18] S [-10**18]+[int(input()) for _ in range(A)]+[10**18] [-10**18]+[int(input()) for _ in range(A)] [-10**18] -10**18 -10 18 [int(input()) for _ in range(A)] [10**18] 10**18 10 18 int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T=[-10**18]+[int(input()) for _ in range(B)]+[10**18] T [-10**18]+[int(input()) for _ in range(B)]+[10**18] [-10**18]+[int(input()) for _ in range(B)] [-10**18] -10**18 -10 18 [int(input()) for _ in range(B)] [10**18] 10**18 10 18 for i in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x)
    ans=float("inf")
    for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
    print(ans) i range(Q) range Q x=int(input()) x int(input()) int input() input b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x) b bisect.bisect_right(S,x) bisect.bisect_right bisect bisect_right S x d bisect.bisect_right(T,x) bisect.bisect_right bisect bisect_right T x ans=float("inf") ans float("inf") float "inf" for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
     s [S[b-1], S[b]] S[b-1] S b-1 b 1 S[b] S b for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
     t [T[d-1], T[d]] T[d-1] T d-1 d 1 T[d] T d d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t) d1 abs(s-x)+abs(t-s) abs(s-x) abs s-x s x abs(t-s) abs t-s t s d2 abs(t-x)+abs(s-t) abs(t-x) abs t-x t x abs(s-t) abs s-t s t ans=min(ans,d1,d2) ans min(ans,d1,d2) min ans d1 d2 print(ans) print ans A,B,Q=map(int,input().split()) map(int,input().split()) A Q=map(int,input().split()) map(int,input().split()) Q S=[-10**18]+[int(input()) for _ in range(A)]+[10**18] [-10**18]+[int(input()) for _ in range(A)]+[10**18] S d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t) abs(t-x)+abs(s-t) d2 x=int(input()) int(input()) x d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t) abs(s-x)+abs(t-s) d1 ans=float("inf") float("inf") ans d=bisect.bisect_right(S,x), bisect.bisect_right(T,x) bisect.bisect_right(T,x) d T=[-10**18]+[int(input()) for _ in range(B)]+[10**18] [-10**18]+[int(input()) for _ in range(B)]+[10**18] T ans=min(ans,d1,d2) min(ans,d1,d2) ans B,Q=map(int,input().split()) map(int,input().split()) B b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x) bisect.bisect_right(S,x) b
import bisect

A,B,Q=map(int,input().split())
S=[-10**18]+[int(input()) for _ in range(A)]+[10**18]
T=[-10**18]+[int(input()) for _ in range(B)]+[10**18]

for i in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x)
    ans=float("inf")
    for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
    print(ans)