from bisect import bisect_left

INF = 2 * 10**10

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
    sr = bisect_left(S, x) 
    sl = sr -1
    if sr != len(S) and S[sr] == x:
        sl = sr
    tr = bisect_left(T, x)
    tl = tr - 1
    if tr != len(T) and T[tr] == x:
        tl = tr

    ll = INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl])
    rr = INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x
    lsrt = INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x)
    ltrs = INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x)
    rslt = INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl])
    rtls = INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl])

    ans.append(min(ll, rr, lsrt, ltrs, rslt, rtls))
print(*ans, sep='\n') from bisect import bisect_left INF = 2 * 10**10 INF 2 * 10**10 2 10**10 10 10 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)] int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input X = [int(input()) for _ in range(Q)] X [int(input()) for _ in range(Q)] ans = [] ans [] for x in X:
    sr = bisect_left(S, x) 
    sl = sr -1
    if sr != len(S) and S[sr] == x:
        sl = sr
    tr = bisect_left(T, x)
    tl = tr - 1
    if tr != len(T) and T[tr] == x:
        tl = tr

    ll = INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl])
    rr = INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x
    lsrt = INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x)
    ltrs = INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x)
    rslt = INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl])
    rtls = INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl])

    ans.append(min(ll, rr, lsrt, ltrs, rslt, rtls)) x X sr = bisect_left(S, x) sr bisect_left(S, x) bisect_left S x sl = sr -1 sl sr -1 sr 1 if sr != len(S) and S[sr] == x:
        sl = sr
     sr != len(S) and S[sr] == x sr != len(S) sr len(S) len S S[sr] == x S[sr] S sr x sl = sr sl sr tr = bisect_left(T, x) tr bisect_left(T, x) bisect_left T x tl = tr - 1 tl tr - 1 tr 1 if tr != len(T) and T[tr] == x:
        tl = tr

     tr != len(T) and T[tr] == x tr != len(T) tr len(T) len T T[tr] == x T[tr] T tr x tl = tr tl tr ll = INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl]) ll INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl]) sl == -1 or tl == -1 sl == -1 sl -1 tl == -1 tl -1 INF x - min(S[sl], T[tl]) x min(S[sl], T[tl]) min S[sl] S sl T[tl] T tl rr = INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x rr INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x sr == len(S) or tr == len(T) sr == len(S) sr len(S) len S tr == len(T) tr len(T) len T INF max(S[sr], T[tr]) - x max(S[sr], T[tr]) max S[sr] S sr T[tr] T tr x lsrt = INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x) lsrt INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x) sl == -1 or tr == len(T) sl == -1 sl -1 tr == len(T) tr len(T) len T INF 2*(x-S[sl]) + (T[tr] - x) 2*(x-S[sl]) 2 x-S[sl] x S[sl] S sl T[tr] - x T[tr] T tr x ltrs = INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x) ltrs INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x) tl == -1 or sr == len(S) tl == -1 tl -1 sr == len(S) sr len(S) len S INF 2*(x-T[tl]) + (S[sr] - x) 2*(x-T[tl]) 2 x-T[tl] x T[tl] T tl S[sr] - x S[sr] S sr x rslt = INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl]) rslt INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl]) tl == -1 or sr == len(S) tl == -1 tl -1 sr == len(S) sr len(S) len S INF 2*(S[sr] - x) + (x - T[tl]) 2*(S[sr] - x) 2 S[sr] - x S[sr] S sr x x - T[tl] x T[tl] T tl rtls = INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl]) rtls INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl]) sl == -1 or tr == len(T) sl == -1 sl -1 tr == len(T) tr len(T) len T INF 2*(T[tr] - x) + (x - S[sl]) 2*(T[tr] - x) 2 T[tr] - x T[tr] T tr x x - S[sl] x S[sl] S sl ans.append(min(ll, rr, lsrt, ltrs, rslt, rtls)) ans.append ans append min(ll, rr, lsrt, ltrs, rslt, rtls) min ll rr lsrt ltrs rslt rtls print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' INF = 2 * 10**10 2 * 10**10 INF rslt = INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl]) INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl]) rslt T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T tr = bisect_left(T, x) bisect_left(T, x) tr tl = tr - 1 tr - 1 tl X = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] X B, Q = map(int, input().split()) map(int, input().split()) B ll = INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl]) INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl]) ll sl = sr -1 sr -1 sl Q = map(int, input().split()) map(int, input().split()) Q ans = [] [] ans rr = INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x rr lsrt = INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x) INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x) lsrt rtls = INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl]) INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl]) rtls S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S sr = bisect_left(S, x) bisect_left(S, x) sr sl = sr sr sl ltrs = INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x) INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x) ltrs A, B, Q = map(int, input().split()) map(int, input().split()) A tl = tr tr tl
from bisect import bisect_left

INF = 2 * 10**10

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
    sr = bisect_left(S, x) 
    sl = sr -1
    if sr != len(S) and S[sr] == x:
        sl = sr
    tr = bisect_left(T, x)
    tl = tr - 1
    if tr != len(T) and T[tr] == x:
        tl = tr

    ll = INF if sl == -1 or tl == -1 else x - min(S[sl], T[tl])
    rr = INF if sr == len(S) or tr == len(T) else max(S[sr], T[tr]) - x
    lsrt = INF if sl == -1 or tr == len(T) else 2*(x-S[sl]) + (T[tr] - x)
    ltrs = INF if tl == -1 or sr == len(S) else 2*(x-T[tl]) + (S[sr] - x)
    rslt = INF if tl == -1 or sr == len(S) else 2*(S[sr] - x) + (x - T[tl])
    rtls = INF if sl == -1 or tr == len(T) else 2*(T[tr] - x) + (x - S[sl])

    ans.append(min(ll, rr, lsrt, ltrs, rslt, rtls))
print(*ans, sep='\n')