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

s.sort()
t.sort()

for k in range(Q):
    x = int(input())
    ans = []
    ms = bisect_left(s, x)
    for i in [-1, 0]:
        if 0 <= ms + i <= A - 1:
            mt = bisect_left(t, s[ms + i])
            for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
    mt = bisect_left(t, x)
    for i in [-1, 0]:
        if 0 <= mt + i <= B - 1:
            ms = bisect_left(s, t[mt + i])
            for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
    print(min(ans)) from bisect import bisect_left A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input s = [int(input()) for _ in range(A)] s [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t = [int(input()) for _ in range(B)] t [int(input()) for _ in range(B)] s.sort() s.sort s sort t.sort() t.sort t sort for k in range(Q):
    x = int(input())
    ans = []
    ms = bisect_left(s, x)
    for i in [-1, 0]:
        if 0 <= ms + i <= A - 1:
            mt = bisect_left(t, s[ms + i])
            for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
    mt = bisect_left(t, x)
    for i in [-1, 0]:
        if 0 <= mt + i <= B - 1:
            ms = bisect_left(s, t[mt + i])
            for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
    print(min(ans)) k range(Q) range Q x = int(input()) x int(input()) int input() input ans = [] ans [] ms = bisect_left(s, x) ms bisect_left(s, x) bisect_left s x for i in [-1, 0]:
        if 0 <= ms + i <= A - 1:
            mt = bisect_left(t, s[ms + i])
            for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
     i [-1, 0] -1 0 if 0 <= ms + i <= A - 1:
            mt = bisect_left(t, s[ms + i])
            for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
     0 <= ms + i <= A - 1 0 <= ms + i 0 ms + i ms i A - 1 A 1 mt = bisect_left(t, s[ms + i]) mt bisect_left(t, s[ms + i]) bisect_left t s[ms + i] s ms + i ms i for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
     j [-1, 0] -1 0 if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
     0 <= mt + j <= B - 1 0 <= mt + j 0 mt + j mt j B - 1 B 1 ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i])) ans.append ans append abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]) abs(s[ms + i] - x) abs s[ms + i] - x s[ms + i] s ms + i ms i x abs(t[mt + j] - s[ms + i]) abs t[mt + j] - s[ms + i] t[mt + j] t mt + j mt j s[ms + i] s ms + i ms i mt = bisect_left(t, x) mt bisect_left(t, x) bisect_left t x for i in [-1, 0]:
        if 0 <= mt + i <= B - 1:
            ms = bisect_left(s, t[mt + i])
            for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
     i [-1, 0] -1 0 if 0 <= mt + i <= B - 1:
            ms = bisect_left(s, t[mt + i])
            for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
     0 <= mt + i <= B - 1 0 <= mt + i 0 mt + i mt i B - 1 B 1 ms = bisect_left(s, t[mt + i]) ms bisect_left(s, t[mt + i]) bisect_left s t[mt + i] t mt + i mt i for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
     j [-1, 0] -1 0 if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
     0 <= ms + j <= A - 1 0 <= ms + j 0 ms + j ms j A - 1 A 1 ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i])) ans.append ans append abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]) abs(t[mt + i] - x) abs t[mt + i] - x t[mt + i] t mt + i mt i x abs(s[ms + j] - t[mt + i]) abs s[ms + j] - t[mt + i] s[ms + j] s ms + j ms j t[mt + i] t mt + i mt i print(min(ans)) print min(ans) min ans A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t ans = [] [] ans ms = bisect_left(s, t[mt + i]) bisect_left(s, t[mt + i]) ms Q = map(int, input().split()) map(int, input().split()) Q x = int(input()) int(input()) x ms = bisect_left(s, x) bisect_left(s, x) ms s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s mt = bisect_left(t, x) bisect_left(t, x) mt mt = bisect_left(t, s[ms + i]) bisect_left(t, s[ms + i]) mt
from bisect import bisect_left
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

s.sort()
t.sort()

for k in range(Q):
    x = int(input())
    ans = []
    ms = bisect_left(s, x)
    for i in [-1, 0]:
        if 0 <= ms + i <= A - 1:
            mt = bisect_left(t, s[ms + i])
            for j in [-1, 0]:
                if 0 <= mt + j <= B - 1:
                    ans.append(abs(s[ms + i] - x) + abs(t[mt + j] - s[ms + i]))
    mt = bisect_left(t, x)
    for i in [-1, 0]:
        if 0 <= mt + i <= B - 1:
            ms = bisect_left(s, t[mt + i])
            for j in [-1, 0]:
                if 0 <= ms + j <= A - 1:
                    ans.append(abs(t[mt + i] - x) + abs(s[ms + j] - t[mt + i]))
    print(min(ans))
