import bisect
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)]

bLeft = bisect.bisect_left

for x in X:
    si = bLeft(S, x)
    sleft = float('inf')
    sright = float('inf')
    if si != 0:
        sleft = x-S[si-1]
    if si != A:
        sright = S[si]-x

    ti = bLeft(T, x)
    tleft = float('inf')
    tright = float('inf')
    if ti != 0:
        tleft = x-T[ti-1]
    if ti != B:
        tright = T[ti]-x

    ans1 = max(sleft, tleft)
    ans2 = max(sright, tright)
    ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright)
    print(min(ans1, ans2, ans3)) 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 = [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)] bLeft = bisect.bisect_left bLeft bisect.bisect_left bisect bisect_left for x in X:
    si = bLeft(S, x)
    sleft = float('inf')
    sright = float('inf')
    if si != 0:
        sleft = x-S[si-1]
    if si != A:
        sright = S[si]-x

    ti = bLeft(T, x)
    tleft = float('inf')
    tright = float('inf')
    if ti != 0:
        tleft = x-T[ti-1]
    if ti != B:
        tright = T[ti]-x

    ans1 = max(sleft, tleft)
    ans2 = max(sright, tright)
    ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright)
    print(min(ans1, ans2, ans3)) x X si = bLeft(S, x) si bLeft(S, x) bLeft S x sleft = float('inf') sleft float('inf') float 'inf' sright = float('inf') sright float('inf') float 'inf' if si != 0:
        sleft = x-S[si-1]
     si != 0 si 0 sleft = x-S[si-1] sleft x-S[si-1] x S[si-1] S si-1 si 1 if si != A:
        sright = S[si]-x

     si != A si A sright = S[si]-x sright S[si]-x S[si] S si x ti = bLeft(T, x) ti bLeft(T, x) bLeft T x tleft = float('inf') tleft float('inf') float 'inf' tright = float('inf') tright float('inf') float 'inf' if ti != 0:
        tleft = x-T[ti-1]
     ti != 0 ti 0 tleft = x-T[ti-1] tleft x-T[ti-1] x T[ti-1] T ti-1 ti 1 if ti != B:
        tright = T[ti]-x

     ti != B ti B tright = T[ti]-x tright T[ti]-x T[ti] T ti x ans1 = max(sleft, tleft) ans1 max(sleft, tleft) max sleft tleft ans2 = max(sright, tright) ans2 max(sright, tright) max sright tright ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright) ans3 min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright) min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) min(min(sleft, sright), min(tleft, tright)) min min(sleft, sright) min sleft sright min(tleft, tright) min tleft tright min(sleft, sright) min sleft sright min(tleft, tright) min tleft tright print(min(ans1, ans2, ans3)) print min(ans1, ans2, ans3) min ans1 ans2 ans3 ans2 = max(sright, tright) max(sright, tright) ans2 S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S sright = S[si]-x S[si]-x sright ans1 = max(sleft, tleft) max(sleft, tleft) ans1 bLeft = bisect.bisect_left bisect.bisect_left bLeft ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright) min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright) ans3 B, Q = map(int, input().split()) map(int, input().split()) B Q = map(int, input().split()) map(int, input().split()) Q sleft = float('inf') float('inf') sleft sleft = x-S[si-1] x-S[si-1] sleft tright = float('inf') float('inf') tright X = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] X tleft = x-T[ti-1] x-T[ti-1] tleft si = bLeft(S, x) bLeft(S, x) si tleft = float('inf') float('inf') tleft T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T tright = T[ti]-x T[ti]-x tright sright = float('inf') float('inf') sright ti = bLeft(T, x) bLeft(T, x) ti A, B, Q = map(int, input().split()) map(int, input().split()) A
import bisect
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)]

bLeft = bisect.bisect_left

for x in X:
    si = bLeft(S, x)
    sleft = float('inf')
    sright = float('inf')
    if si != 0:
        sleft = x-S[si-1]
    if si != A:
        sright = S[si]-x

    ti = bLeft(T, x)
    tleft = float('inf')
    tright = float('inf')
    if ti != 0:
        tleft = x-T[ti-1]
    if ti != B:
        tright = T[ti]-x

    ans1 = max(sleft, tleft)
    ans2 = max(sright, tright)
    ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright)
    print(min(ans1, ans2, ans3))
