import sys
input = lambda: sys.stdin.readline().rstrip()
import bisect

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

INF = 10 ** 18

s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for i in range(Q):
    x = int(input())
    right_s = bisect.bisect_right(s, x)
    right_t = bisect.bisect_right(t, x)

    ans = INF
    
    for S in [s[right_s-1], s[right_s]]:
        for T in [t[right_t-1], t[right_t]]:
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

    print(ans) import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip import bisect bisect A,B,Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q INF = 10 ** 18 INF 10 ** 18 10 18 int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input s = [-INF] + [int(input()) for _ in range(A)] + [INF] s [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] [-INF] -INF INF [int(input()) for _ in range(A)] [INF] INF int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t = [-INF] + [int(input()) for _ in range(B)] + [INF] t [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] [-INF] -INF INF [int(input()) for _ in range(B)] [INF] INF for i in range(Q):
    x = int(input())
    right_s = bisect.bisect_right(s, x)
    right_t = bisect.bisect_right(t, x)

    ans = INF
    
    for S in [s[right_s-1], s[right_s]]:
        for T in [t[right_t-1], t[right_t]]:
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

    print(ans) i range(Q) range Q x = int(input()) x int(input()) int input() input right_s = bisect.bisect_right(s, x) right_s bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x right_t = bisect.bisect_right(t, x) right_t bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x ans = INF ans INF for S in [s[right_s-1], s[right_s]]:
        for T in [t[right_t-1], t[right_t]]:
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

     S [s[right_s-1], s[right_s]] s[right_s-1] s right_s-1 right_s 1 s[right_s] s right_s for T in [t[right_t-1], t[right_t]]:
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

     T [t[right_t-1], t[right_t]] t[right_t-1] t right_t-1 right_t 1 t[right_t] t right_t ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)) ans min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)) min ans abs(x-S) + abs(T-S) abs(x-S) abs x-S x S abs(T-S) abs T-S T S abs(x-T) + abs(S-T) abs(x-T) abs x-T x T abs(S-T) abs S-T S T print(ans) print ans ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)) min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)) ans INF = 10 ** 18 10 ** 18 INF right_t = bisect.bisect_right(t, x) bisect.bisect_right(t, x) right_t s = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] s Q = map(int, input().split()) map(int, input().split()) Q right_s = bisect.bisect_right(s, x) bisect.bisect_right(s, x) right_s ans = INF INF ans x = int(input()) int(input()) x B,Q = map(int, input().split()) map(int, input().split()) B t = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] t input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input A,B,Q = map(int, input().split()) map(int, input().split()) A
import sys
input = lambda: sys.stdin.readline().rstrip()
import bisect

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

INF = 10 ** 18

s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for i in range(Q):
    x = int(input())
    right_s = bisect.bisect_right(s, x)
    right_t = bisect.bisect_right(t, x)

    ans = INF
    
    for S in [s[right_s-1], s[right_s]]:
        for T in [t[right_t-1], t[right_t]]:
            ans = min(ans, abs(x-S) + abs(T-S), abs(x-T) + abs(S-T))

    print(ans)