import bisect

INF=10**18
A,B,Q=map(int,input().split())
S=[0]*(A+2)
T=[0]*(B+2)
S[0],T[0]=-INF,-INF
S[A+1],T[B+1]=INF,INF

for i in range(1,A+1):
    S[i]=int(input())

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

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

INF=10**18
A,B,Q=map(int,input().split())
S=[0]*(A+2)
T=[0]*(B+2)
S[0],T[0]=-INF,-INF
S[A+1],T[B+1]=INF,INF

for i in range(1,A+1):
    S[i]=int(input())

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

for i in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x)
    ans=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)