from bisect import bisect_left

A, B, Q = map(int, input().split())
INF = 10**18
S = [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF]
T = [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF]

S.sort()
T.sort()

for _ in range(Q):
    x = int(input())

    s = bisect_left(S, x)
    ls = S[s - 1]
    rs = S[s]

    t = bisect_left(T, x)
    lt = T[t - 1]
    rt = T[t]

    ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    )

    print(ans) from bisect import bisect_left 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 = [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF] S [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF] [int(input()) for _ in range(A)] [INF, INF, -INF, -INF] INF INF -INF INF -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 = [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF] T [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF] [int(input()) for _ in range(B)] [INF, INF, -INF, -INF] INF INF -INF INF -INF INF S.sort() S.sort S sort T.sort() T.sort T sort for _ in range(Q):
    x = int(input())

    s = bisect_left(S, x)
    ls = S[s - 1]
    rs = S[s]

    t = bisect_left(T, x)
    lt = T[t - 1]
    rt = T[t]

    ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    )

    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input s = bisect_left(S, x) s bisect_left(S, x) bisect_left S x ls = S[s - 1] ls S[s - 1] S s - 1 s 1 rs = S[s] rs S[s] S s t = bisect_left(T, x) t bisect_left(T, x) bisect_left T x lt = T[t - 1] lt T[t - 1] T t - 1 t 1 rt = T[t] rt T[t] T t ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    ) ans min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    ) min abs(ls - rt) + min(abs(x - ls), abs(x - rt)) abs(ls - rt) abs ls - rt ls rt min(abs(x - ls), abs(x - rt)) min abs(x - ls) abs x - ls x ls abs(x - rt) abs x - rt x rt abs(lt - rs) + min(abs(x - lt), abs(x - rs)) abs(lt - rs) abs lt - rs lt rs min(abs(x - lt), abs(x - rs)) min abs(x - lt) abs x - lt x lt abs(x - rs) abs x - rs x rs max(abs(x - ls), abs(x - lt)) max abs(x - ls) abs x - ls x ls abs(x - lt) abs x - lt x lt max(abs(x - rs), abs(x - rt)) max abs(x - rs) abs x - rs x rs abs(x - rt) abs x - rt x rt print(ans) print ans lt = T[t - 1] T[t - 1] lt rt = T[t] T[t] rt Q = map(int, input().split()) map(int, input().split()) Q rs = S[s] S[s] rs T = [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF] [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF] T ls = S[s - 1] S[s - 1] ls A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B S = [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF] [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF] S INF = 10**18 10**18 INF s = bisect_left(S, x) bisect_left(S, x) s t = bisect_left(T, x) bisect_left(T, x) t x = int(input()) int(input()) x ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    ) min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    ) ans
from bisect import bisect_left

A, B, Q = map(int, input().split())
INF = 10**18
S = [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF]
T = [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF]

S.sort()
T.sort()

for _ in range(Q):
    x = int(input())

    s = bisect_left(S, x)
    ls = S[s - 1]
    rs = S[s]

    t = bisect_left(T, x)
    lt = T[t - 1]
    rt = T[t]

    ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    )

    print(ans)
