import bisect

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



a=[-float("inf")]

b=[-float("inf")]

for i in range(A):

    a.append(int(eval(input())))

for i in range(B):

    b.append(int(eval(input())))   

a+=[float("inf")]

b+=[float("inf")]



for i in range(Q):

    q = int(eval(input()))

    x = bisect.bisect_left(a, q)

    y = bisect.bisect_left(b, q)

    ans = float("inf")

    for j in [a[x-1], a[x]]:

        for k in [b[y-1], b[y]]:

            ans1 = abs(j-q)+abs(j-k)

            ans2 = abs(k-q)+abs(j-k)

            ans = min(ans, ans1, ans2)

    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 i in range(Q):

    x = int(eval(input()))

    s = bisect.bisect_left(S, x)

    t = bisect.bisect_left(T, x)

    saisyo = float("inf")

    for j in [S[s], S[s-1]]:

        for k in [T[t], T[t-1]]:

            saisyo = min(saisyo, abs(j-x)+abs(k-j), abs(k-x)+abs(j-k))

    print(saisyo)
import bisect

A, B, Q = list(map(int, input().split()))
a = [-float("inf")]
b = [-float("inf")]
for i in range(A):
    a.append(int(eval(input())))
for i in range(B):
    b.append(int(eval(input())))
a += [float("inf")]
b += [float("inf")]
for i in range(Q):
    q = int(eval(input()))
    x = bisect.bisect_left(a, q)
    y = bisect.bisect_left(b, q)
    ans = float("inf")
    for j in [a[x - 1], a[x]]:
        for k in [b[y - 1], b[y]]:
            ans1 = abs(j - q) + abs(j - k)
            ans2 = abs(k - q) + abs(j - k)
            ans = min(ans, ans1, ans2)
    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 i in range(Q):
    x = int(eval(input()))
    s = bisect.bisect_left(S, x)
    t = bisect.bisect_left(T, x)
    saisyo = float("inf")
    for j in [S[s], S[s - 1]]:
        for k in [T[t], T[t - 1]]:
            saisyo = min(saisyo, abs(j - x) + abs(k - j), abs(k - x) + abs(j - k))
    print(saisyo)

-a = [-float("inf")] -b = [-float("inf")] -for i in range(A): -    a.append(int(eval(input()))) -for i in range(B): -    b.append(int(eval(input()))) -a += [float("inf")] -b += [float("inf")] +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] -    q = int(eval(input())) -    x = bisect.bisect_left(a, q) -    y = bisect.bisect_left(b, q) -    ans = float("inf") -    for j in [a[x - 1], a[x]]: -        for k in [b[y - 1], b[y]]: -            ans1 = abs(j - q) + abs(j - k) -            ans2 = abs(k - q) + abs(j - k) -            ans = min(ans, ans1, ans2) -    print(ans) +    x = int(eval(input())) +    s = bisect.bisect_left(S, x) +    t = bisect.bisect_left(T, x) +    saisyo = float("inf") +    for j in [S[s], S[s - 1]]: +        for k in [T[t], T[t - 1]]: +            saisyo = min(saisyo, abs(j - x) + abs(k - j), abs(k - x) + abs(j - k)) +    print(saisyo)