import bisect

 

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

INF = float('inf')

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()))

    b = bisect.bisect_right(s, x)

    d = bisect.bisect_right(t, x)

    ans = INF

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

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

            ans1 = abs(S-x) + abs(S-T)

            ans2 = abs(T-x) + abs(T-S)

            ans = min(ans, ans1, ans2)

    print(ans)
#左右それぞれで一番近い神社

#その神社それぞれの左右それぞれで一番近い寺

#はい２ぶたん



INF = 10**12



from bisect import bisect_right

 

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

s = [int(eval(input())) for i in range(A)]

t = [int(eval(input())) for i in range(B)]

ans =[]

for i in range(0,Q,1):

    tmpans = INF



    q = int(eval(input()))

    sr = bisect_right(s,q)

    sl = sr-1

    sr = min(sr,A-1)

    sl = max(0,sl)

    for j in (sr,sl):

        tr = bisect_right(t,s[j])

        tl = tr-1

        tr = min(tr,B-1)

        tl = max(0,tl)

        ansR=abs(s[j]-q)+abs(s[j]-t[tr])

        ansL=abs(s[j]-q)+abs(s[j]-t[tl])

        tmpans = min(tmpans,ansR,ansL)



    

    tr = bisect_right(t,q)

    tl = tr-1

    tr = min(tr,B-1)

    tl = max(0,tl)

    for j in (tr,tl):

        sr = bisect_right(s,t[j])

        sl = sr-1

        sr = min(sr,A-1)

        sl = max(0,sl)

        ansR=abs(t[j]-q)+abs(t[j]-s[sr])

        ansL=abs(t[j]-q)+abs(t[j]-s[sl])

        tmpans = min(tmpans,ansR,ansL)

    

    ans.append(tmpans)



for i in range(0,Q,1):

    print((ans[i]))
import bisect

A, B, Q = list(map(int, input().split()))
INF = float("inf")
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()))
    b = bisect.bisect_right(s, x)
    d = bisect.bisect_right(t, x)
    ans = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            ans1 = abs(S - x) + abs(S - T)
            ans2 = abs(T - x) + abs(T - S)
            ans = min(ans, ans1, ans2)
    print(ans)

# 左右それぞれで一番近い神社
# その神社それぞれの左右それぞれで一番近い寺
# はい２ぶたん
INF = 10**12
from bisect import bisect_right

A, B, Q = list(map(int, input().split()))
s = [int(eval(input())) for i in range(A)]
t = [int(eval(input())) for i in range(B)]
ans = []
for i in range(0, Q, 1):
    tmpans = INF
    q = int(eval(input()))
    sr = bisect_right(s, q)
    sl = sr - 1
    sr = min(sr, A - 1)
    sl = max(0, sl)
    for j in (sr, sl):
        tr = bisect_right(t, s[j])
        tl = tr - 1
        tr = min(tr, B - 1)
        tl = max(0, tl)
        ansR = abs(s[j] - q) + abs(s[j] - t[tr])
        ansL = abs(s[j] - q) + abs(s[j] - t[tl])
        tmpans = min(tmpans, ansR, ansL)
    tr = bisect_right(t, q)
    tl = tr - 1
    tr = min(tr, B - 1)
    tl = max(0, tl)
    for j in (tr, tl):
        sr = bisect_right(s, t[j])
        sl = sr - 1
        sr = min(sr, A - 1)
        sl = max(0, sl)
        ansR = abs(t[j] - q) + abs(t[j] - s[sr])
        ansL = abs(t[j] - q) + abs(t[j] - s[sl])
        tmpans = min(tmpans, ansR, ansL)
    ans.append(tmpans)
for i in range(0, Q, 1):
    print((ans[i]))

-import bisect +# 左右それぞれで一番近い神社 +# その神社それぞれの左右それぞれで一番近い寺 +# はい２ぶたん +INF = 10**12 +from bisect import bisect_right -INF = float("inf") -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())) -    b = bisect.bisect_right(s, x) -    d = bisect.bisect_right(t, x) -    ans = INF -    for S in [s[b - 1], s[b]]: -        for T in [t[d - 1], t[d]]: -            ans1 = abs(S - x) + abs(S - T) -            ans2 = abs(T - x) + abs(T - S) -            ans = min(ans, ans1, ans2) -    print(ans) +s = [int(eval(input())) for i in range(A)] +t = [int(eval(input())) for i in range(B)] +ans = [] +for i in range(0, Q, 1): +    tmpans = INF +    q = int(eval(input())) +    sr = bisect_right(s, q) +    sl = sr - 1 +    sr = min(sr, A - 1) +    sl = max(0, sl) +    for j in (sr, sl): +        tr = bisect_right(t, s[j]) +        tl = tr - 1 +        tr = min(tr, B - 1) +        tl = max(0, tl) +        ansR = abs(s[j] - q) + abs(s[j] - t[tr]) +        ansL = abs(s[j] - q) + abs(s[j] - t[tl]) +        tmpans = min(tmpans, ansR, ansL) +    tr = bisect_right(t, q) +    tl = tr - 1 +    tr = min(tr, B - 1) +    tl = max(0, tl) +    for j in (tr, tl): +        sr = bisect_right(s, t[j]) +        sl = sr - 1 +        sr = min(sr, A - 1) +        sl = max(0, sl) +        ansR = abs(t[j] - q) + abs(t[j] - s[sr]) +        ansL = abs(t[j] - q) + abs(t[j] - s[sl]) +        tmpans = min(tmpans, ansR, ansL) +    ans.append(tmpans) +for i in range(0, Q, 1): +    print((ans[i]))