from bisect import bisect_right, bisect_left

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]



for _ in range(Q):

    x = int(eval(input()))



    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1]

    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)]



    ans = min(

        abs(lS - lT) + (x - max(lS, lT)),

        abs(rS - rT) + (min(rS, rT) - x),

        (rT - lS) + min(x - lS, rT - x),

        (rS - lT) + min(x - lT, rS - x)

    )



    print(ans)

from bisect import bisect_left



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

INF = 10**18

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

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



S.sort()

T.sort()



for _ in range(Q):

    x = int(eval(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_right, bisect_left

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]
for _ in range(Q):
    x = int(eval(input()))
    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1]
    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)]
    ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x),
    )
    print(ans)

from bisect import bisect_left

A, B, Q = list(map(int, input().split()))
INF = 10**18
S = [int(eval(input())) for _ in range(A)] + [INF, INF, -INF, -INF]
T = [int(eval(input())) for _ in range(B)] + [INF, INF, -INF, -INF]
S.sort()
T.sort()
for _ in range(Q):
    x = int(eval(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_right, bisect_left +from bisect import bisect_left -S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] -T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] +S = [int(eval(input())) for _ in range(A)] + [INF, INF, -INF, -INF] +T = [int(eval(input())) for _ in range(B)] + [INF, INF, -INF, -INF] +S.sort() +T.sort() -    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1] -    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)] +    s = bisect_left(S, x) +    ls = S[s - 1] +    rs = S[s] +    t = bisect_left(T, x) +    lt = T[t - 1] +    rt = T[t] -        abs(lS - lT) + (x - max(lS, lT)), -        abs(rS - rT) + (min(rS, rT) - x), -        (rT - lS) + min(x - lS, rT - x), -        (rS - lT) + min(x - lT, rS - x), +        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)),