from bisect import bisect_right

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

S = [int(eval(input())) for _ in range(A)]

S.append(10**11)

S.insert(0,-10**11)

T = [int(eval(input())) for _ in range(B)]

T.append(10**11)

T.insert(0,-10**11)

Ds = {i:0 for i in range(1,A+1)}

Ds[A+1] = 10**11

Ds[0] = 10**11

for i in range(1,A+1):

    ind = bisect_right(T,S[i])

    Ds[i] = min(T[ind]-S[i],S[i]-T[ind-1])

Dt = {j:0 for j in range(1,B+1)}

Dt[B+1] = 10**11

Dt[0] = 10**11

for j in range(1,B+1):

    ind = bisect_right(S,T[j])

    Dt[j] = min(S[ind]-T[j],T[j]-S[ind-1])

for _ in range(Q):

    x = int(eval(input()))

    inds = bisect_right(S,x)

    cnts = min(S[inds]-x+Ds[inds],x-S[inds-1]+Ds[inds-1])

    indt = bisect_right(T,x)

    cntt = min(T[indt]-x+Dt[indt],x-T[indt-1]+Dt[indt-1])

    print((min(cnts,cntt)))

    
from bisect import bisect_right

INFTY = 10**11

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

S = [int(eval(input())) for _ in range(A)]

S.insert(0,-INFTY)

S.append(INFTY)

T = [int(eval(input())) for _ in range(B)]

T.insert(0,-INFTY)

T.append(INFTY)

for _ in range(Q):

    x = int(eval(input()))

    indS = bisect_right(S,x)

    indT = bisect_right(T,x)

    d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1])

    d2 = x-S[indS-1]+abs(S[indS-1]-T[indT])

    d3 = S[indS]-x+abs(S[indS]-T[indT-1])

    d4 = S[indS]-x+abs(S[indS]-T[indT])

    d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1])

    d6 = x-T[indT-1]+abs(T[indT-1]-S[indS])

    d7 = T[indT]-x+abs(T[indT]-S[indS-1])

    d8 = T[indT]-x+abs(T[indT]-S[indS])

    print((min(d1,d2,d3,d4,d5,d6,d7,d8)))
from bisect import bisect_right

A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
S.append(10**11)
S.insert(0, -(10**11))
T = [int(eval(input())) for _ in range(B)]
T.append(10**11)
T.insert(0, -(10**11))
Ds = {i: 0 for i in range(1, A + 1)}
Ds[A + 1] = 10**11
Ds[0] = 10**11
for i in range(1, A + 1):
    ind = bisect_right(T, S[i])
    Ds[i] = min(T[ind] - S[i], S[i] - T[ind - 1])
Dt = {j: 0 for j in range(1, B + 1)}
Dt[B + 1] = 10**11
Dt[0] = 10**11
for j in range(1, B + 1):
    ind = bisect_right(S, T[j])
    Dt[j] = min(S[ind] - T[j], T[j] - S[ind - 1])
for _ in range(Q):
    x = int(eval(input()))
    inds = bisect_right(S, x)
    cnts = min(S[inds] - x + Ds[inds], x - S[inds - 1] + Ds[inds - 1])
    indt = bisect_right(T, x)
    cntt = min(T[indt] - x + Dt[indt], x - T[indt - 1] + Dt[indt - 1])
    print((min(cnts, cntt)))

from bisect import bisect_right

INFTY = 10**11
A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
S.insert(0, -INFTY)
S.append(INFTY)
T = [int(eval(input())) for _ in range(B)]
T.insert(0, -INFTY)
T.append(INFTY)
for _ in range(Q):
    x = int(eval(input()))
    indS = bisect_right(S, x)
    indT = bisect_right(T, x)
    d1 = x - S[indS - 1] + abs(S[indS - 1] - T[indT - 1])
    d2 = x - S[indS - 1] + abs(S[indS - 1] - T[indT])
    d3 = S[indS] - x + abs(S[indS] - T[indT - 1])
    d4 = S[indS] - x + abs(S[indS] - T[indT])
    d5 = x - T[indT - 1] + abs(T[indT - 1] - S[indS - 1])
    d6 = x - T[indT - 1] + abs(T[indT - 1] - S[indS])
    d7 = T[indT] - x + abs(T[indT] - S[indS - 1])
    d8 = T[indT] - x + abs(T[indT] - S[indS])
    print((min(d1, d2, d3, d4, d5, d6, d7, d8)))

+INFTY = 10**11 -S.append(10**11) -S.insert(0, -(10**11)) +S.insert(0, -INFTY) +S.append(INFTY) -T.append(10**11) -T.insert(0, -(10**11)) -Ds = {i: 0 for i in range(1, A + 1)} -Ds[A + 1] = 10**11 -Ds[0] = 10**11 -for i in range(1, A + 1): -    ind = bisect_right(T, S[i]) -    Ds[i] = min(T[ind] - S[i], S[i] - T[ind - 1]) -Dt = {j: 0 for j in range(1, B + 1)} -Dt[B + 1] = 10**11 -Dt[0] = 10**11 -for j in range(1, B + 1): -    ind = bisect_right(S, T[j]) -    Dt[j] = min(S[ind] - T[j], T[j] - S[ind - 1]) +T.insert(0, -INFTY) +T.append(INFTY) -    inds = bisect_right(S, x) -    cnts = min(S[inds] - x + Ds[inds], x - S[inds - 1] + Ds[inds - 1]) -    indt = bisect_right(T, x) -    cntt = min(T[indt] - x + Dt[indt], x - T[indt - 1] + Dt[indt - 1]) -    print((min(cnts, cntt))) +    indS = bisect_right(S, x) +    indT = bisect_right(T, x) +    d1 = x - S[indS - 1] + abs(S[indS - 1] - T[indT - 1]) +    d2 = x - S[indS - 1] + abs(S[indS - 1] - T[indT]) +    d3 = S[indS] - x + abs(S[indS] - T[indT - 1]) +    d4 = S[indS] - x + abs(S[indS] - T[indT]) +    d5 = x - T[indT - 1] + abs(T[indT - 1] - S[indS - 1]) +    d6 = x - T[indT - 1] + abs(T[indT - 1] - S[indS]) +    d7 = T[indT] - x + abs(T[indT] - S[indS - 1]) +    d8 = T[indT] - x + abs(T[indT] - S[indS]) +    print((min(d1, d2, d3, d4, d5, d6, d7, d8)))