from bisect import bisect_right



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



INF = 10 ** 18

s = [-INF] + s + [INF]

t = [-INF] + t + [INF]



for i in range(Q):

    b = bisect_right(s, x[i])

    d = bisect_right(t, x[i])

    res = INF

    for n in [s[b - 1], s[b]]:

        for m in [t[d - 1], t[d]]:

            d1 = abs(n - x[i]) + abs(m - n)

            d2 = abs(m - x[i]) + abs(n - m)

            res = min(res, d1, d2)

    print(res)



from bisect import bisect_right



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

INF = 10 ** 18

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

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

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



for x in X:

    b = bisect_right(S, x)

    d = bisect_right(T, x)

    res = INF

    for s in [S[b - 1], S[b]]:

        for t in [T[d - 1], T[d]]:

            dist_0 = abs(x - s) + abs(s - t)

            dist_1 = abs(x - t) + abs(t - s)

            res = min(res, dist_0, dist_1)



    print(res)

from bisect import bisect_right

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)]
INF = 10**18
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]
for i in range(Q):
    b = bisect_right(s, x[i])
    d = bisect_right(t, x[i])
    res = INF
    for n in [s[b - 1], s[b]]:
        for m in [t[d - 1], t[d]]:
            d1 = abs(n - x[i]) + abs(m - n)
            d2 = abs(m - x[i]) + abs(n - m)
            res = min(res, d1, d2)
    print(res)

from bisect import bisect_right

A, B, Q = list(map(int, input().split()))
INF = 10**18
S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
X = [int(eval(input())) for _ in range(Q)]
for x in X:
    b = bisect_right(S, x)
    d = bisect_right(T, x)
    res = INF
    for s in [S[b - 1], S[b]]:
        for t in [T[d - 1], T[d]]:
            dist_0 = abs(x - s) + abs(s - t)
            dist_1 = abs(x - t) + abs(t - s)
            res = min(res, dist_0, dist_1)
    print(res)

-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 = [-INF] + s + [INF] -t = [-INF] + t + [INF] -for i in range(Q): -    b = bisect_right(s, x[i]) -    d = bisect_right(t, x[i]) +S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] +T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] +X = [int(eval(input())) for _ in range(Q)] +for x in X: +    b = bisect_right(S, x) +    d = bisect_right(T, x) -    for n in [s[b - 1], s[b]]: -        for m in [t[d - 1], t[d]]: -            d1 = abs(n - x[i]) + abs(m - n) -            d2 = abs(m - x[i]) + abs(n - m) -            res = min(res, d1, d2) +    for s in [S[b - 1], S[b]]: +        for t in [T[d - 1], T[d]]: +            dist_0 = abs(x - s) + abs(s - t) +            dist_1 = abs(x - t) + abs(t - s) +            res = min(res, dist_0, dist_1)