import bisect





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

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

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

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

for i in x:

    si = bisect.bisect_left(s, i)

    ti = bisect.bisect_left(t, i)

    s1, s2 = s[si - 1], s[si]

    t1, t2 = t[ti - 1], t[ti]

    ans = 10 ** 12

    for ss in [s1, s2]:

        for tt in [t1, t2]:

            ans = min(ans, abs(i - ss) + abs(ss - tt),

                      abs(i - tt) + abs(ss - tt))

    print(ans)
import bisect





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

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

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

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

S = [-10 ** 12] + S + [10 ** 12]

T = [-10 ** 12] + T + [10 ** 12]

for x in X:

    si = bisect.bisect_right(S, x)

    ti = bisect.bisect_right(T, x)

    Ls, Rs = x - S[si - 1], -x + S[si]

    Lt, Rt = x - T[ti - 1], -x + T[ti]

    ans = min(Ls * 2 + Rt, Ls + Rt * 2, Lt * 2 + Rs,

              Lt + Rs * 2, max(Ls, Lt), max(Rs, Rt))

    print(ans)

import bisect

A, B, Q = list(map(int, input().split()))
s = [-(10**12)] + [int(eval(input())) for _ in range(A)] + [10**12]
t = [-(10**12)] + [int(eval(input())) for _ in range(B)] + [10**12]
x = [int(eval(input())) for _ in range(Q)]
for i in x:
    si = bisect.bisect_left(s, i)
    ti = bisect.bisect_left(t, i)
    s1, s2 = s[si - 1], s[si]
    t1, t2 = t[ti - 1], t[ti]
    ans = 10**12
    for ss in [s1, s2]:
        for tt in [t1, t2]:
            ans = min(ans, abs(i - ss) + abs(ss - tt), abs(i - tt) + abs(ss - tt))
    print(ans)

import bisect

A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
X = [int(eval(input())) for _ in range(Q)]
S = [-(10**12)] + S + [10**12]
T = [-(10**12)] + T + [10**12]
for x in X:
    si = bisect.bisect_right(S, x)
    ti = bisect.bisect_right(T, x)
    Ls, Rs = x - S[si - 1], -x + S[si]
    Lt, Rt = x - T[ti - 1], -x + T[ti]
    ans = min(
        Ls * 2 + Rt, Ls + Rt * 2, Lt * 2 + Rs, Lt + Rs * 2, max(Ls, Lt), max(Rs, Rt)
    )
    print(ans)

-s = [-(10**12)] + [int(eval(input())) for _ in range(A)] + [10**12] -t = [-(10**12)] + [int(eval(input())) for _ in range(B)] + [10**12] -x = [int(eval(input())) for _ in range(Q)] -for i in x: -    si = bisect.bisect_left(s, i) -    ti = bisect.bisect_left(t, i) -    s1, s2 = s[si - 1], s[si] -    t1, t2 = t[ti - 1], t[ti] -    ans = 10**12 -    for ss in [s1, s2]: -        for tt in [t1, t2]: -            ans = min(ans, abs(i - ss) + abs(ss - tt), abs(i - tt) + abs(ss - tt)) +S = [int(eval(input())) for _ in range(A)] +T = [int(eval(input())) for _ in range(B)] +X = [int(eval(input())) for _ in range(Q)] +S = [-(10**12)] + S + [10**12] +T = [-(10**12)] + T + [10**12] +for x in X: +    si = bisect.bisect_right(S, x) +    ti = bisect.bisect_right(T, x) +    Ls, Rs = x - S[si - 1], -x + S[si] +    Lt, Rt = x - T[ti - 1], -x + T[ti] +    ans = min( +        Ls * 2 + Rt, Ls + Rt * 2, Lt * 2 + Rs, Lt + Rs * 2, max(Ls, Lt), max(Rs, Rt) +    )