from bisect import bisect_right



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

INF = 10**20



s = [0] * A

t = [0] * B

x = [0] * Q



for i in range(A) :

    s[i] = int(eval(input()))

for i in range(B) :

    t[i] = int(eval(input()))

for i in range(Q) :

    x[i] = int(eval(input()))



s = [-INF] + s + [INF]

t = [-INF] + t + [INF]



for p in x :

    rightS = bisect_right(s,p)

    rightT = bisect_right(t,p)



    dist = INF



    for ss in [s[rightS - 1], s[rightS]] :

        for tt in [t[rightT - 1], t[rightT]] :

            dist1 = abs(ss - p) + abs(ss - tt)

            dist2 = abs(tt - p) + abs(tt - ss)

            dist = min(dist, dist1, dist2)



    print(dist)

from bisect import bisect_left, bisect_right



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

S = [int(input()) for _ in range(A)] + [float('inf'), -float('inf')]

T = [int(input()) for _ in range(B)] + [float('inf'), -float('inf')]



S.sort()

T.sort()



ans = []

for _ in range(Q):

    x = int(input())



    midS = bisect_right(S, x)

    midT = bisect_right(T, x)



    lS = S[midS - 1]

    rS = S[midS]

    lT = T[midT - 1]

    rT = T[midT]



    dist = min(

        max(rS, rT) - x,

        x - min(lS, lT),

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

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

    )



    ans.append(dist)



print(*ans, sep='\n')

from bisect import bisect_right

A, B, Q = list(map(int, input().split()))
INF = 10**20
s = [0] * A
t = [0] * B
x = [0] * Q
for i in range(A):
    s[i] = int(eval(input()))
for i in range(B):
    t[i] = int(eval(input()))
for i in range(Q):
    x[i] = int(eval(input()))
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]
for p in x:
    rightS = bisect_right(s, p)
    rightT = bisect_right(t, p)
    dist = INF
    for ss in [s[rightS - 1], s[rightS]]:
        for tt in [t[rightT - 1], t[rightT]]:
            dist1 = abs(ss - p) + abs(ss - tt)
            dist2 = abs(tt - p) + abs(tt - ss)
            dist = min(dist, dist1, dist2)
    print(dist)

from bisect import bisect_left, bisect_right

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)] + [float("inf"), -float("inf")]
T = [int(input()) for _ in range(B)] + [float("inf"), -float("inf")]
S.sort()
T.sort()
ans = []
for _ in range(Q):
    x = int(input())
    midS = bisect_right(S, x)
    midT = bisect_right(T, x)
    lS = S[midS - 1]
    rS = S[midS]
    lT = T[midT - 1]
    rT = T[midT]
    dist = min(
        max(rS, rT) - x,
        x - min(lS, lT),
        abs(rS - lT) + min(rS - x, x - lT),
        abs(rT - lS) + min(rT - x, x - lS),
    )
    ans.append(dist)
print(*ans, sep="\n")

-from bisect import bisect_right +from bisect import bisect_left, bisect_right -A, B, Q = list(map(int, input().split())) -INF = 10**20 -s = [0] * A -t = [0] * B -x = [0] * Q -for i in range(A): -    s[i] = int(eval(input())) -for i in range(B): -    t[i] = int(eval(input())) -for i in range(Q): -    x[i] = int(eval(input())) -s = [-INF] + s + [INF] -t = [-INF] + t + [INF] -for p in x: -    rightS = bisect_right(s, p) -    rightT = bisect_right(t, p) -    dist = INF -    for ss in [s[rightS - 1], s[rightS]]: -        for tt in [t[rightT - 1], t[rightT]]: -            dist1 = abs(ss - p) + abs(ss - tt) -            dist2 = abs(tt - p) + abs(tt - ss) -            dist = min(dist, dist1, dist2) -    print(dist) +A, B, Q = map(int, input().split()) +S = [int(input()) for _ in range(A)] + [float("inf"), -float("inf")] +T = [int(input()) for _ in range(B)] + [float("inf"), -float("inf")] +S.sort() +T.sort() +ans = [] +for _ in range(Q): +    x = int(input()) +    midS = bisect_right(S, x) +    midT = bisect_right(T, x) +    lS = S[midS - 1] +    rS = S[midS] +    lT = T[midT - 1] +    rT = T[midT] +    dist = min( +        max(rS, rT) - x, +        x - min(lS, lT), +        abs(rS - lT) + min(rS - x, x - lT), +        abs(rT - lS) + min(rT - x, x - lS), +    ) +    ans.append(dist) +print(*ans, sep="\n")