from bisect import bisect_right

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

INF = 10 ** 18

s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]

t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]

xs = [int(eval(input())) for i in range(Q)]

for x in xs:

    b, d = bisect_right(s, x), bisect_right(t, x)

    res = INF

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

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

            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)

            res = min(res, d1, d2)

    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]





# 指定した変位に対する問に二分探索を用いて回答

def f(y):

    i = bisect_right(S, y)

    j = bisect_right(T, y)

    return min(

        abs(b - a) + min(abs(a - y), abs(b - y))

        for a in (S[i - 1], S[i])

        for b in (T[j - 1], T[j])

    )





# 各問に対して、fにより解を得る

ans = '\n'.join(map(str, list(map(f, x))))



# 出力

print(ans)

from bisect import bisect_right

A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
xs = [int(eval(input())) for i in range(Q)]
for x in xs:
    b, d = bisect_right(s, x), bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    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]
# 指定した変位に対する問に二分探索を用いて回答
def f(y):
    i = bisect_right(S, y)
    j = bisect_right(T, y)
    return min(
        abs(b - a) + min(abs(a - y), abs(b - y))
        for a in (S[i - 1], S[i])
        for b in (T[j - 1], T[j])
    )


# 各問に対して、fにより解を得る
ans = "\n".join(map(str, list(map(f, x))))
# 出力
print(ans)

+# 入力 +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] + [int(eval(input())) for i in range(A)] + [INF] -t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] -xs = [int(eval(input())) for i in range(Q)] -for x in xs: -    b, d = bisect_right(s, x), bisect_right(t, x) -    res = INF -    for S in [s[b - 1], s[b]]: -        for T in [t[d - 1], t[d]]: -            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) -            res = min(res, d1, d2) -    print(res) +S = [-INF] + s + [INF] +T = [-INF] + t + [INF] +# 指定した変位に対する問に二分探索を用いて回答 +def f(y): +    i = bisect_right(S, y) +    j = bisect_right(T, y) +    return min( +        abs(b - a) + min(abs(a - y), abs(b - y)) +        for a in (S[i - 1], S[i]) +        for b in (T[j - 1], T[j]) +    ) + + +# 各問に対して、fにより解を得る +ans = "\n".join(map(str, list(map(f, x)))) +# 出力 +print(ans)