import bisect

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

INF = 10 ** 18

s = [-INF]

t = [-INF]

for _ in range(A):

    s.append(int(eval(input())))

s.append(INF)

for _ in range(B):

    t.append(int(eval(input())))

t.append(INF)

for q in range(Q):

    x = int(eval(input()))

    i, j = bisect.bisect_right(s, x), bisect.bisect_right(t, x)

    ans = min(

        max(abs(s[i] - x), abs(t[j] - x)),

        max(abs(s[i - 1] - x), abs(t[j - 1] - x)),

        2 * min(abs(s[i] - x), abs(t[j - 1] - x)) + max(abs(s[i] - x), abs(t[j - 1] - x)),

        2 * min(abs(s[i - 1] - x), abs(t[j] - x)) + max(abs(s[i - 1] - x), abs(t[j] - 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)

import bisect

A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF]
t = [-INF]
for _ in range(A):
    s.append(int(eval(input())))
s.append(INF)
for _ in range(B):
    t.append(int(eval(input())))
t.append(INF)
for q in range(Q):
    x = int(eval(input()))
    i, j = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    ans = min(
        max(abs(s[i] - x), abs(t[j] - x)),
        max(abs(s[i - 1] - x), abs(t[j - 1] - x)),
        2 * min(abs(s[i] - x), abs(t[j - 1] - x))
        + max(abs(s[i] - x), abs(t[j - 1] - x)),
        2 * min(abs(s[i - 1] - x), abs(t[j] - x))
        + max(abs(s[i - 1] - x), abs(t[j] - 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)

-import bisect +from bisect import bisect_right -s = [-INF] -t = [-INF] -for _ in range(A): -    s.append(int(eval(input()))) -s.append(INF) -for _ in range(B): -    t.append(int(eval(input()))) -t.append(INF) -for q in range(Q): -    x = int(eval(input())) -    i, j = bisect.bisect_right(s, x), bisect.bisect_right(t, x) -    ans = min( -        max(abs(s[i] - x), abs(t[j] - x)), -        max(abs(s[i - 1] - x), abs(t[j - 1] - x)), -        2 * min(abs(s[i] - x), abs(t[j - 1] - x)) -        + max(abs(s[i] - x), abs(t[j - 1] - x)), -        2 * min(abs(s[i - 1] - x), abs(t[j] - x)) -        + max(abs(s[i - 1] - x), abs(t[j] - x)), -    ) -    print(ans) +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)