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

a=[-float("inf")]
b=[-float("inf")]
for i in range(A):
    a.append(int(input()))
for i in range(B):
    b.append(int(input()))   
a+=[float("inf")]
b+=[float("inf")]

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

a=[-float("inf")]
b=[-float("inf")]
for i in range(A):
    a.append(int(input()))
for i in range(B):
    b.append(int(input()))   
a+=[float("inf")]
b+=[float("inf")]

for i in range(Q):
    q = int(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)