from bisect import bisect_left, bisect_right
A,B,Q = map(int,input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
for _ in range(Q):
    x = int(input())
    a = bisect_right(s, x)
    b = bisect_right(t, x)
    la = x-s[a-1] if a > 0 else None
    ra = s[a]-x if a < A else None
    lb = x-t[b-1] if b > 0 else None
    rb = t[b]-x if b < B else None
    ans = float("inf")
    if la and lb:
        ans = min(ans, max(la, lb))
    if la and rb:
        ans = min(ans, la+2*rb, 2*la+rb)
    if ra and lb:
        ans = min(ans, ra+2*lb, 2*ra+lb)
    if ra and rb:
        ans = min(ans, max(ra, rb))
    print(ans) from bisect import bisect_left, bisect_right 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)] for _ in range(Q):
    x = int(input())
    a = bisect_right(s, x)
    b = bisect_right(t, x)
    la = x-s[a-1] if a > 0 else None
    ra = s[a]-x if a < A else None
    lb = x-t[b-1] if b > 0 else None
    rb = t[b]-x if b < B else None
    ans = float("inf")
    if la and lb:
        ans = min(ans, max(la, lb))
    if la and rb:
        ans = min(ans, la+2*rb, 2*la+rb)
    if ra and lb:
        ans = min(ans, ra+2*lb, 2*ra+lb)
    if ra and rb:
        ans = min(ans, max(ra, rb))
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input a = bisect_right(s, x) a bisect_right(s, x) bisect_right s x b = bisect_right(t, x) b bisect_right(t, x) bisect_right t x la = x-s[a-1] if a > 0 else None la x-s[a-1] if a > 0 else None a > 0 a 0 x-s[a-1] x s[a-1] s a-1 a 1 None ra = s[a]-x if a < A else None ra s[a]-x if a < A else None a < A a A s[a]-x s[a] s a x None lb = x-t[b-1] if b > 0 else None lb x-t[b-1] if b > 0 else None b > 0 b 0 x-t[b-1] x t[b-1] t b-1 b 1 None rb = t[b]-x if b < B else None rb t[b]-x if b < B else None b < B b B t[b]-x t[b] t b x None ans = float("inf") ans float("inf") float "inf" if la and lb:
        ans = min(ans, max(la, lb))
     la and lb la lb ans = min(ans, max(la, lb)) ans min(ans, max(la, lb)) min ans max(la, lb) max la lb if la and rb:
        ans = min(ans, la+2*rb, 2*la+rb)
     la and rb la rb ans = min(ans, la+2*rb, 2*la+rb) ans min(ans, la+2*rb, 2*la+rb) min ans la+2*rb la 2*rb 2 rb 2*la+rb 2*la 2 la rb if ra and lb:
        ans = min(ans, ra+2*lb, 2*ra+lb)
     ra and lb ra lb ans = min(ans, ra+2*lb, 2*ra+lb) ans min(ans, ra+2*lb, 2*ra+lb) min ans ra+2*lb ra 2*lb 2 lb 2*ra+lb 2*ra 2 ra lb if ra and rb:
        ans = min(ans, max(ra, rb))
     ra and rb ra rb ans = min(ans, max(ra, rb)) ans min(ans, max(ra, rb)) min ans max(ra, rb) max ra rb print(ans) print ans ans = min(ans, ra+2*lb, 2*ra+lb) min(ans, ra+2*lb, 2*ra+lb) ans ans = float("inf") float("inf") ans s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s Q = map(int,input().split()) map(int,input().split()) Q ra = s[a]-x if a < A else None s[a]-x if a < A else None ra la = x-s[a-1] if a > 0 else None x-s[a-1] if a > 0 else None la lb = x-t[b-1] if b > 0 else None x-t[b-1] if b > 0 else None lb rb = t[b]-x if b < B else None t[b]-x if b < B else None rb ans = min(ans, max(ra, rb)) min(ans, max(ra, rb)) ans a = bisect_right(s, x) bisect_right(s, x) a t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t b = bisect_right(t, x) bisect_right(t, x) b ans = min(ans, max(la, lb)) min(ans, max(la, lb)) ans B,Q = map(int,input().split()) map(int,input().split()) B x = int(input()) int(input()) x A,B,Q = map(int,input().split()) map(int,input().split()) A ans = min(ans, la+2*rb, 2*la+rb) min(ans, la+2*rb, 2*la+rb) ans
from bisect import bisect_left, bisect_right
A,B,Q = map(int,input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
for _ in range(Q):
    x = int(input())
    a = bisect_right(s, x)
    b = bisect_right(t, x)
    la = x-s[a-1] if a > 0 else None
    ra = s[a]-x if a < A else None
    lb = x-t[b-1] if b > 0 else None
    rb = t[b]-x if b < B else None
    ans = float("inf")
    if la and lb:
        ans = min(ans, max(la, lb))
    if la and rb:
        ans = min(ans, la+2*rb, 2*la+rb)
    if ra and lb:
        ans = min(ans, ra+2*lb, 2*ra+lb)
    if ra and rb:
        ans = min(ans, max(ra, rb))
    print(ans)