
from bisect import bisect_right

A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(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 = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q INF = 10 ** 18 INF 10 ** 18 10 18 int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [-INF] + [int(input()) for _ in range(A)] + [INF] S [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] [-INF] -INF INF [int(input()) for _ in range(A)] [INF] INF int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [-INF] + [int(input()) for _ in range(B)] + [INF] T [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] [-INF] -INF INF [int(input()) for _ in range(B)] [INF] INF int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input X = [int(input()) for _ in range(Q)] X [int(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) x X b = bisect_right(S, x) b bisect_right(S, x) bisect_right S x d = bisect_right(T, x) d bisect_right(T, x) bisect_right T x res = INF 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)

     s [S[b - 1], S[b]] S[b - 1] S b - 1 b 1 S[b] 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)

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

from bisect import bisect_right

A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(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)
