import bisect

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]

for q in range(Q):

	x = int(eval(input()))

	b, d = bisect.bisect_right(s, x), bisect.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()))

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)

x = list(map(int, (eval(input()) for _ in range(Q))))

for y in x:

    i = bisect_right(s, y)

    j = bisect_right(t, y)

    # ans = INF

    # for S in [s[i - 1], s[i]]:

    #     for T in [t[j - 1], t[j]]:

    #         d1, d2 = abs(S - y) + abs(T - S), abs(T - y) + abs(S - T)

    #         ans = min(ans, d1, d2)

    ans = min(

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

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

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

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

    )

    print(ans)
import bisect

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]
for q in range(Q):
    x = int(eval(input()))
    b, d = bisect.bisect_right(s, x), bisect.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()))
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)
x = list(map(int, (eval(input()) for _ in range(Q))))
for y in x:
    i = bisect_right(s, y)
    j = bisect_right(t, y)
    # ans = INF
    # for S in [s[i - 1], s[i]]:
    #     for T in [t[j - 1], t[j]]:
    #         d1, d2 = abs(S - y) + abs(T - S), abs(T - y) + abs(S - T)
    #         ans = min(ans, d1, d2)
    ans = min(
        max(abs(s[i] - y), abs(t[j] - y)),
        max(abs(s[i - 1] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i] - y), abs(t[j - 1] - y))
        + max(abs(s[i] - y), abs(t[j - 1] - y)),
        2 * min(abs(s[i - 1] - y), abs(t[j] - y))
        + max(abs(s[i - 1] - y), abs(t[j] - y)),
    )
    print(ans)

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