from bisect import bisect_left

A, B, Q = list(map(int, input().split()))

S = [-10**11] + [int(eval(input())) for _ in range(A)] + [10**11]

T = [-10**11] + [int(eval(input())) for _ in range(B)] + [10**11]

X = [int(eval(input())) for _ in range(Q)]



S1 = [0]*A

T1 = [0]*B

for i, s in enumerate(S[1:-1]):

    x = bisect_left(T, s)

    S1[i] = (s, min(abs(s - T[x-1]), abs(T[x] - s)))

for i, t in enumerate(T[1:-1]):

    x = bisect_left(S, t)

    T1[i] = (t, min(abs(t - S[x-1]), abs(S[x] - t)))

ST = S1 + T1

ST.sort()

ST = [(-10**11, 10**11)] + ST + [(10**11, 10**11)]

bist, dist = list(map(list, list(zip(*ST))))

for d in X:

    x = bisect_left(bist, d)

    print((min(abs(d - bist[x-1]) + dist[x-1], abs(bist[x] - d) + dist[x])))

import sys

from bisect import bisect as br

A, B, Q = list(map(int, input().split()))

inf = 10**11

S = [-inf] + [int(sys.stdin.readline()) for _ in range(A)] + [inf]

T = [-inf] + [int(sys.stdin.readline()) for _ in range(B)] + [inf]

X = [int(sys.stdin.readline()) for _ in range(Q)]



StoT = [0]*A

for i, s in enumerate(S[1:-1]):

    x = br(T, s)

    StoT[i] = (s, min(s - T[x-1], T[x] - s))



TtoS = [0]*B

for i, t in enumerate(T[1:-1]):

    x = br(S, t)

    TtoS[i] = (t, min(t - S[x-1], S[x] - t))



M = [(-inf, inf)] + TtoS + StoT + [(inf, inf)]

M.sort()

Mk , Mv = list(map(list, list(zip(*M))))

for x in X:

    idx = br(Mk, x)

    print((min(Mk[idx] - x + Mv[idx], x - Mk[idx-1] + Mv[idx-1])))

from bisect import bisect_left

A, B, Q = list(map(int, input().split()))
S = [-(10**11)] + [int(eval(input())) for _ in range(A)] + [10**11]
T = [-(10**11)] + [int(eval(input())) for _ in range(B)] + [10**11]
X = [int(eval(input())) for _ in range(Q)]
S1 = [0] * A
T1 = [0] * B
for i, s in enumerate(S[1:-1]):
    x = bisect_left(T, s)
    S1[i] = (s, min(abs(s - T[x - 1]), abs(T[x] - s)))
for i, t in enumerate(T[1:-1]):
    x = bisect_left(S, t)
    T1[i] = (t, min(abs(t - S[x - 1]), abs(S[x] - t)))
ST = S1 + T1
ST.sort()
ST = [(-(10**11), 10**11)] + ST + [(10**11, 10**11)]
bist, dist = list(map(list, list(zip(*ST))))
for d in X:
    x = bisect_left(bist, d)
    print((min(abs(d - bist[x - 1]) + dist[x - 1], abs(bist[x] - d) + dist[x])))

import sys
from bisect import bisect as br

A, B, Q = list(map(int, input().split()))
inf = 10**11
S = [-inf] + [int(sys.stdin.readline()) for _ in range(A)] + [inf]
T = [-inf] + [int(sys.stdin.readline()) for _ in range(B)] + [inf]
X = [int(sys.stdin.readline()) for _ in range(Q)]
StoT = [0] * A
for i, s in enumerate(S[1:-1]):
    x = br(T, s)
    StoT[i] = (s, min(s - T[x - 1], T[x] - s))
TtoS = [0] * B
for i, t in enumerate(T[1:-1]):
    x = br(S, t)
    TtoS[i] = (t, min(t - S[x - 1], S[x] - t))
M = [(-inf, inf)] + TtoS + StoT + [(inf, inf)]
M.sort()
Mk, Mv = list(map(list, list(zip(*M))))
for x in X:
    idx = br(Mk, x)
    print((min(Mk[idx] - x + Mv[idx], x - Mk[idx - 1] + Mv[idx - 1])))

-from bisect import bisect_left +import sys +from bisect import bisect as br -S = [-(10**11)] + [int(eval(input())) for _ in range(A)] + [10**11] -T = [-(10**11)] + [int(eval(input())) for _ in range(B)] + [10**11] -X = [int(eval(input())) for _ in range(Q)] -S1 = [0] * A -T1 = [0] * B +inf = 10**11 +S = [-inf] + [int(sys.stdin.readline()) for _ in range(A)] + [inf] +T = [-inf] + [int(sys.stdin.readline()) for _ in range(B)] + [inf] +X = [int(sys.stdin.readline()) for _ in range(Q)] +StoT = [0] * A -    x = bisect_left(T, s) -    S1[i] = (s, min(abs(s - T[x - 1]), abs(T[x] - s))) +    x = br(T, s) +    StoT[i] = (s, min(s - T[x - 1], T[x] - s)) +TtoS = [0] * B -    x = bisect_left(S, t) -    T1[i] = (t, min(abs(t - S[x - 1]), abs(S[x] - t))) -ST = S1 + T1 -ST.sort() -ST = [(-(10**11), 10**11)] + ST + [(10**11, 10**11)] -bist, dist = list(map(list, list(zip(*ST)))) -for d in X: -    x = bisect_left(bist, d) -    print((min(abs(d - bist[x - 1]) + dist[x - 1], abs(bist[x] - d) + dist[x]))) +    x = br(S, t) +    TtoS[i] = (t, min(t - S[x - 1], S[x] - t)) +M = [(-inf, inf)] + TtoS + StoT + [(inf, inf)] +M.sort() +Mk, Mv = list(map(list, list(zip(*M)))) +for x in X: +    idx = br(Mk, x) +    print((min(Mk[idx] - x + Mv[idx], x - Mk[idx - 1] + Mv[idx - 1])))