import bisect
A, B, Q = map(int, input().split())
s = list(int(input()) for _ in range(A))
t = list(int(input()) for _ in range(B))

for i in range(Q):
    ans = 10 ** 19
    x = int(input())
    stmp1 = bisect.bisect_left(s, x)
    for j in range(2):
        if stmp1 == 0 and j == 1:
            continue
        if stmp1 == A and j == 0:
            continue
        ttmp1 = bisect.bisect_left(t, s[stmp1 - j])
        ktmp = 10 ** 11
        if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
        if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
        total = abs(x - s[stmp1 - j]) + ktmp
        ans = min(ans, total)

    ttmp1 = bisect.bisect_left(t, x)
    for j in range(2):
        if ttmp1 == 0 and j == 1:
            continue
        if ttmp1 == B and j == 0:
            continue
        stmp1 = bisect.bisect_left(s, t[ttmp1 - j])
        ktmp = 10 ** 11
        if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
        if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
        total = abs(x - t[ttmp1 - j]) + ktmp
        ans = min(ans, total)
    print(ans) import bisect bisect A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q s = list(int(input()) for _ in range(A)) s list(int(input()) for _ in range(A)) list int(input()) int input() input t = list(int(input()) for _ in range(B)) t list(int(input()) for _ in range(B)) list int(input()) int input() input for i in range(Q):
    ans = 10 ** 19
    x = int(input())
    stmp1 = bisect.bisect_left(s, x)
    for j in range(2):
        if stmp1 == 0 and j == 1:
            continue
        if stmp1 == A and j == 0:
            continue
        ttmp1 = bisect.bisect_left(t, s[stmp1 - j])
        ktmp = 10 ** 11
        if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
        if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
        total = abs(x - s[stmp1 - j]) + ktmp
        ans = min(ans, total)

    ttmp1 = bisect.bisect_left(t, x)
    for j in range(2):
        if ttmp1 == 0 and j == 1:
            continue
        if ttmp1 == B and j == 0:
            continue
        stmp1 = bisect.bisect_left(s, t[ttmp1 - j])
        ktmp = 10 ** 11
        if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
        if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
        total = abs(x - t[ttmp1 - j]) + ktmp
        ans = min(ans, total)
    print(ans) i range(Q) range Q ans = 10 ** 19 ans 10 ** 19 10 19 x = int(input()) x int(input()) int input() input stmp1 = bisect.bisect_left(s, x) stmp1 bisect.bisect_left(s, x) bisect.bisect_left bisect bisect_left s x for j in range(2):
        if stmp1 == 0 and j == 1:
            continue
        if stmp1 == A and j == 0:
            continue
        ttmp1 = bisect.bisect_left(t, s[stmp1 - j])
        ktmp = 10 ** 11
        if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
        if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
        total = abs(x - s[stmp1 - j]) + ktmp
        ans = min(ans, total)

     j range(2) range 2 if stmp1 == 0 and j == 1:
            continue
         stmp1 == 0 and j == 1 stmp1 == 0 stmp1 0 j == 1 j 1 continue if stmp1 == A and j == 0:
            continue
         stmp1 == A and j == 0 stmp1 == A stmp1 A j == 0 j 0 continue ttmp1 = bisect.bisect_left(t, s[stmp1 - j]) ttmp1 bisect.bisect_left(t, s[stmp1 - j]) bisect.bisect_left bisect bisect_left t s[stmp1 - j] s stmp1 - j stmp1 j ktmp = 10 ** 11 ktmp 10 ** 11 10 11 if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
         ttmp1 != 0 ttmp1 0 ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1])) ktmp min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1])) min ktmp abs(s[stmp1 - j] - t[ttmp1 - 1]) abs s[stmp1 - j] - t[ttmp1 - 1] s[stmp1 - j] s stmp1 - j stmp1 j t[ttmp1 - 1] t ttmp1 - 1 ttmp1 1 if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
         ttmp1 != B ttmp1 B ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1])) ktmp min(ktmp, abs(s[stmp1 - j] - t[ttmp1])) min ktmp abs(s[stmp1 - j] - t[ttmp1]) abs s[stmp1 - j] - t[ttmp1] s[stmp1 - j] s stmp1 - j stmp1 j t[ttmp1] t ttmp1 total = abs(x - s[stmp1 - j]) + ktmp total abs(x - s[stmp1 - j]) + ktmp abs(x - s[stmp1 - j]) abs x - s[stmp1 - j] x s[stmp1 - j] s stmp1 - j stmp1 j ktmp ans = min(ans, total) ans min(ans, total) min ans total ttmp1 = bisect.bisect_left(t, x) ttmp1 bisect.bisect_left(t, x) bisect.bisect_left bisect bisect_left t x for j in range(2):
        if ttmp1 == 0 and j == 1:
            continue
        if ttmp1 == B and j == 0:
            continue
        stmp1 = bisect.bisect_left(s, t[ttmp1 - j])
        ktmp = 10 ** 11
        if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
        if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
        total = abs(x - t[ttmp1 - j]) + ktmp
        ans = min(ans, total)
     j range(2) range 2 if ttmp1 == 0 and j == 1:
            continue
         ttmp1 == 0 and j == 1 ttmp1 == 0 ttmp1 0 j == 1 j 1 continue if ttmp1 == B and j == 0:
            continue
         ttmp1 == B and j == 0 ttmp1 == B ttmp1 B j == 0 j 0 continue stmp1 = bisect.bisect_left(s, t[ttmp1 - j]) stmp1 bisect.bisect_left(s, t[ttmp1 - j]) bisect.bisect_left bisect bisect_left s t[ttmp1 - j] t ttmp1 - j ttmp1 j ktmp = 10 ** 11 ktmp 10 ** 11 10 11 if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
         stmp1 != 0 stmp1 0 ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1])) ktmp min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1])) min ktmp abs(t[ttmp1 - j] - s[stmp1 - 1]) abs t[ttmp1 - j] - s[stmp1 - 1] t[ttmp1 - j] t ttmp1 - j ttmp1 j s[stmp1 - 1] s stmp1 - 1 stmp1 1 if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
         stmp1 != A stmp1 A ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1])) ktmp min(ktmp, abs(t[ttmp1 - j] - s[stmp1])) min ktmp abs(t[ttmp1 - j] - s[stmp1]) abs t[ttmp1 - j] - s[stmp1] t[ttmp1 - j] t ttmp1 - j ttmp1 j s[stmp1] s stmp1 total = abs(x - t[ttmp1 - j]) + ktmp total abs(x - t[ttmp1 - j]) + ktmp abs(x - t[ttmp1 - j]) abs x - t[ttmp1 - j] x t[ttmp1 - j] t ttmp1 - j ttmp1 j ktmp ans = min(ans, total) ans min(ans, total) min ans total print(ans) print ans total = abs(x - t[ttmp1 - j]) + ktmp abs(x - t[ttmp1 - j]) + ktmp total ttmp1 = bisect.bisect_left(t, x) bisect.bisect_left(t, x) ttmp1 ans = 10 ** 19 10 ** 19 ans t = list(int(input()) for _ in range(B)) list(int(input()) for _ in range(B)) t x = int(input()) int(input()) x s = list(int(input()) for _ in range(A)) list(int(input()) for _ in range(A)) s stmp1 = bisect.bisect_left(s, t[ttmp1 - j]) bisect.bisect_left(s, t[ttmp1 - j]) stmp1 ans = min(ans, total) min(ans, total) ans stmp1 = bisect.bisect_left(s, x) bisect.bisect_left(s, x) stmp1 total = abs(x - s[stmp1 - j]) + ktmp abs(x - s[stmp1 - j]) + ktmp total ktmp = 10 ** 11 10 ** 11 ktmp ans = min(ans, total) min(ans, total) ans A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1])) min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1])) ktmp ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1])) min(ktmp, abs(s[stmp1 - j] - t[ttmp1])) ktmp ktmp = 10 ** 11 10 ** 11 ktmp Q = map(int, input().split()) map(int, input().split()) Q ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1])) min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1])) ktmp ttmp1 = bisect.bisect_left(t, s[stmp1 - j]) bisect.bisect_left(t, s[stmp1 - j]) ttmp1 ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1])) min(ktmp, abs(t[ttmp1 - j] - s[stmp1])) ktmp
import bisect
A, B, Q = map(int, input().split())
s = list(int(input()) for _ in range(A))
t = list(int(input()) for _ in range(B))

for i in range(Q):
    ans = 10 ** 19
    x = int(input())
    stmp1 = bisect.bisect_left(s, x)
    for j in range(2):
        if stmp1 == 0 and j == 1:
            continue
        if stmp1 == A and j == 0:
            continue
        ttmp1 = bisect.bisect_left(t, s[stmp1 - j])
        ktmp = 10 ** 11
        if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
        if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
        total = abs(x - s[stmp1 - j]) + ktmp
        ans = min(ans, total)

    ttmp1 = bisect.bisect_left(t, x)
    for j in range(2):
        if ttmp1 == 0 and j == 1:
            continue
        if ttmp1 == B and j == 0:
            continue
        stmp1 = bisect.bisect_left(s, t[ttmp1 - j])
        ktmp = 10 ** 11
        if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
        if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
        total = abs(x - t[ttmp1 - j]) + ktmp
        ans = min(ans, total)
    print(ans)