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 _ in range(Q):
    x = int(input())
    s = bisect.bisect_right(S, x)
    t = bisect.bisect_right(T, x)
    s %= A
    t %= B
    ans = 2*10**10
    for i in range(2):
        for j in range(2):
            ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])))
    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 _ in range(Q):
    x = int(input())
    s = bisect.bisect_right(S, x)
    t = bisect.bisect_right(T, x)
    s %= A
    t %= B
    ans = 2*10**10
    for i in range(2):
        for j in range(2):
            ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])))
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input s = bisect.bisect_right(S, x) s bisect.bisect_right(S, x) bisect.bisect_right bisect bisect_right S x t = bisect.bisect_right(T, x) t bisect.bisect_right(T, x) bisect.bisect_right bisect bisect_right T x s %= A s A t %= B t B ans = 2*10**10 ans 2*10**10 2 10**10 10 10 for i in range(2):
        for j in range(2):
            ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])))
     i range(2) range 2 for j in range(2):
            ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])))
     j range(2) range 2 ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i]))) ans min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i]))) min ans min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])) min abs(x-S[s-i])+abs(S[s-i]-T[t-j]) abs(x-S[s-i]) abs x-S[s-i] x S[s-i] S s-i s i abs(S[s-i]-T[t-j]) abs S[s-i]-T[t-j] S[s-i] S s-i s i T[t-j] T t-j t j abs(x-T[t-j])+abs(T[t-j]-S[s-i]) abs(x-T[t-j]) abs x-T[t-j] x T[t-j] T t-j t j abs(T[t-j]-S[s-i]) abs T[t-j]-S[s-i] T[t-j] T t-j t j S[s-i] S s-i s i print(ans) print ans x = int(input()) int(input()) x t %= B B t Q = map(int, input().split()) map(int, input().split()) Q S = list(int(input()) for _ in range(A)) list(int(input()) for _ in range(A)) S t = bisect.bisect_right(T, x) bisect.bisect_right(T, x) t A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B s = bisect.bisect_right(S, x) bisect.bisect_right(S, x) s T = list(int(input()) for _ in range(B)) list(int(input()) for _ in range(B)) T ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i]))) min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i]))) ans s %= A A s ans = 2*10**10 2*10**10 ans
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 _ in range(Q):
    x = int(input())
    s = bisect.bisect_right(S, x)
    t = bisect.bisect_right(T, x)
    s %= A
    t %= B
    ans = 2*10**10
    for i in range(2):
        for j in range(2):
            ans = min(ans, min(abs(x-S[s-i])+abs(S[s-i]-T[t-j]), abs(x-T[t-j])+abs(T[t-j]-S[s-i])))
    print(ans)
