from bisect import bisect_left

INF = 2 * 10**10

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

    ll = x - min(S[sl], T[tl])
    rr = max(S[sr], T[tr]) - x
    lsrt = 2*(x-S[sl]) + (T[tr] - x)
    ltrs = 2*(x-T[tl]) + (S[sr] - x)
    rslt = 2*(S[sr] - x) + (x - T[tl])
    rtls = 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 = [-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 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 if S[sr] == x else sr -1
    tr = bisect_left(T, x)
    tl = tr if T[tr] == x else tr -1

    ll = x - min(S[sl], T[tl])
    rr = max(S[sr], T[tr]) - x
    lsrt = 2*(x-S[sl]) + (T[tr] - x)
    ltrs = 2*(x-T[tl]) + (S[sr] - x)
    rslt = 2*(S[sr] - x) + (x - T[tl])
    rtls = 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 if S[sr] == x else sr -1 sl sr if S[sr] == x else sr -1 S[sr] == x S[sr] S sr x sr sr -1 sr 1 tr = bisect_left(T, x) tr bisect_left(T, x) bisect_left T x tl = tr if T[tr] == x else tr -1 tl tr if T[tr] == x else tr -1 T[tr] == x T[tr] T tr x tr tr -1 tr 1 ll = x - min(S[sl], T[tl]) ll x - min(S[sl], T[tl]) x min(S[sl], T[tl]) min S[sl] S sl T[tl] T tl rr = max(S[sr], T[tr]) - x rr max(S[sr], T[tr]) - x max(S[sr], T[tr]) max S[sr] S sr T[tr] T tr x lsrt = 2*(x-S[sl]) + (T[tr] - x) lsrt 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 = 2*(x-T[tl]) + (S[sr] - x) ltrs 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 = 2*(S[sr] - x) + (x - T[tl]) rslt 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 = 2*(T[tr] - x) + (x - S[sl]) rtls 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' tl = tr if T[tr] == x else tr -1 tr if T[tr] == x else tr -1 tl Q = map(int, input().split()) map(int, input().split()) Q ll = x - min(S[sl], T[tl]) x - min(S[sl], T[tl]) ll ans = [] [] ans rr = max(S[sr], T[tr]) - x max(S[sr], T[tr]) - x rr ltrs = 2*(x-T[tl]) + (S[sr] - x) 2*(x-T[tl]) + (S[sr] - x) ltrs X = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] X S = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] S A, B, Q = map(int, input().split()) map(int, input().split()) A tr = bisect_left(T, x) bisect_left(T, x) tr B, Q = map(int, input().split()) map(int, input().split()) B INF = 2 * 10**10 2 * 10**10 INF sr = bisect_left(S, x) bisect_left(S, x) sr lsrt = 2*(x-S[sl]) + (T[tr] - x) 2*(x-S[sl]) + (T[tr] - x) lsrt sl = sr if S[sr] == x else sr -1 sr if S[sr] == x else sr -1 sl rslt = 2*(S[sr] - x) + (x - T[tl]) 2*(S[sr] - x) + (x - T[tl]) rslt rtls = 2*(T[tr] - x) + (x - S[sl]) 2*(T[tr] - x) + (x - S[sl]) rtls T = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] T
from bisect import bisect_left

INF = 2 * 10**10

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

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

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