A,B,Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
import bisect
for _ in range(Q):
    x = int(input())
    s_idx = bisect.bisect_left(S, x)
    t_idx = bisect.bisect_left(T, x)
    if s_idx == A and t_idx == B:
        ans = x-min(S[-1], T[-1])
    elif s_idx == A and t_idx == 0:
        ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1])
    elif t_idx == B and s_idx == 0:
        ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1])
    elif s_idx == A:
        ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1])
    elif t_idx == B:
        ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1])
    elif s_idx == 0 and t_idx == 0:
        ans = max(S[0], T[0])-x
    elif s_idx == 0:
        ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0])
    elif t_idx == 0:
        ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0])
    else:
        ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1])
        ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx])
    print(ans) 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)] import bisect bisect for _ in range(Q):
    x = int(input())
    s_idx = bisect.bisect_left(S, x)
    t_idx = bisect.bisect_left(T, x)
    if s_idx == A and t_idx == B:
        ans = x-min(S[-1], T[-1])
    elif s_idx == A and t_idx == 0:
        ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1])
    elif t_idx == B and s_idx == 0:
        ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1])
    elif s_idx == A:
        ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1])
    elif t_idx == B:
        ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1])
    elif s_idx == 0 and t_idx == 0:
        ans = max(S[0], T[0])-x
    elif s_idx == 0:
        ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0])
    elif t_idx == 0:
        ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0])
    else:
        ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1])
        ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx])
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input s_idx = bisect.bisect_left(S, x) s_idx bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x t_idx = bisect.bisect_left(T, x) t_idx bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x if s_idx == A and t_idx == B:
        ans = x-min(S[-1], T[-1])
    elif s_idx == A and t_idx == 0:
        ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1])
    elif t_idx == B and s_idx == 0:
        ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1])
    elif s_idx == A:
        ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1])
    elif t_idx == B:
        ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1])
    elif s_idx == 0 and t_idx == 0:
        ans = max(S[0], T[0])-x
    elif s_idx == 0:
        ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0])
    elif t_idx == 0:
        ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0])
    else:
        ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1])
        ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx])
     s_idx == A and t_idx == B s_idx == A s_idx A t_idx == B t_idx B ans = x-min(S[-1], T[-1]) ans x-min(S[-1], T[-1]) x min(S[-1], T[-1]) min S[-1] S -1 T[-1] T -1 elif s_idx == A and t_idx == 0:
        ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1])
     s_idx == A and t_idx == 0 s_idx == A s_idx A t_idx == 0 t_idx 0 ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1]) ans min(x-S[-1]*2+T[0], T[0]*2-x-S[-1]) min x-S[-1]*2+T[0] x-S[-1]*2 x S[-1]*2 S[-1] S -1 2 T[0] T 0 T[0]*2-x-S[-1] T[0]*2-x T[0]*2 T[0] T 0 2 x S[-1] S -1 elif t_idx == B and s_idx == 0:
        ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1])
     t_idx == B and s_idx == 0 t_idx == B t_idx B s_idx == 0 s_idx 0 ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1]) ans min(x-T[-1]*2+S[0], S[0]*2-x-T[-1]) min x-T[-1]*2+S[0] x-T[-1]*2 x T[-1]*2 T[-1] T -1 2 S[0] S 0 S[0]*2-x-T[-1] S[0]*2-x S[0]*2 S[0] S 0 2 x T[-1] T -1 elif s_idx == A:
        ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1])
     s_idx == A s_idx A ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1]) ans min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1]) min x-min(S[-1], T[t_idx-1]) x min(S[-1], T[t_idx-1]) min S[-1] S -1 T[t_idx-1] T t_idx-1 t_idx 1 x-S[-1]*2+T[t_idx] x-S[-1]*2 x S[-1]*2 S[-1] S -1 2 T[t_idx] T t_idx T[t_idx]*2-x-S[-1] T[t_idx]*2-x T[t_idx]*2 T[t_idx] T t_idx 2 x S[-1] S -1 elif t_idx == B:
        ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1])
     t_idx == B t_idx B ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1]) ans min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1]) min x-min(T[-1], S[s_idx-1]) x min(T[-1], S[s_idx-1]) min T[-1] T -1 S[s_idx-1] S s_idx-1 s_idx 1 x-T[-1]*2+S[s_idx] x-T[-1]*2 x T[-1]*2 T[-1] T -1 2 S[s_idx] S s_idx S[s_idx]*2-x-T[-1] S[s_idx]*2-x S[s_idx]*2 S[s_idx] S s_idx 2 x T[-1] T -1 elif s_idx == 0 and t_idx == 0:
        ans = max(S[0], T[0])-x
     s_idx == 0 and t_idx == 0 s_idx == 0 s_idx 0 t_idx == 0 t_idx 0 ans = max(S[0], T[0])-x ans max(S[0], T[0])-x max(S[0], T[0]) max S[0] S 0 T[0] T 0 x elif s_idx == 0:
        ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0])
     s_idx == 0 s_idx 0 ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0]) ans min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0]) min max(S[0], T[t_idx])-x max(S[0], T[t_idx]) max S[0] S 0 T[t_idx] T t_idx x S[0]*2-x-T[t_idx-1] S[0]*2-x S[0]*2 S[0] S 0 2 x T[t_idx-1] T t_idx-1 t_idx 1 x-T[t_idx-1]*2+S[0] x-T[t_idx-1]*2 x T[t_idx-1]*2 T[t_idx-1] T t_idx-1 t_idx 1 2 S[0] S 0 elif t_idx == 0:
        ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0])
     t_idx == 0 t_idx 0 ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0]) ans min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0]) min max(T[0], S[s_idx])-x max(T[0], S[s_idx]) max T[0] T 0 S[s_idx] S s_idx x T[0]*2-x-S[s_idx-1] T[0]*2-x T[0]*2 T[0] T 0 2 x S[s_idx-1] S s_idx-1 s_idx 1 x-S[s_idx-1]*2+T[0] x-S[s_idx-1]*2 x S[s_idx-1]*2 S[s_idx-1] S s_idx-1 s_idx 1 2 T[0] T 0 ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1]) ans min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1]) min max(S[s_idx], T[t_idx])-x max(S[s_idx], T[t_idx]) max S[s_idx] S s_idx T[t_idx] T t_idx x x-min(S[s_idx-1], T[t_idx-1]) x min(S[s_idx-1], T[t_idx-1]) min S[s_idx-1] S s_idx-1 s_idx 1 T[t_idx-1] T t_idx-1 t_idx 1 S[s_idx]*2-x-T[t_idx-1] S[s_idx]*2-x S[s_idx]*2 S[s_idx] S s_idx 2 x T[t_idx-1] T t_idx-1 t_idx 1 T[t_idx]*2-x-S[s_idx-1] T[t_idx]*2-x T[t_idx]*2 T[t_idx] T t_idx 2 x S[s_idx-1] S s_idx-1 s_idx 1 ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx]) ans min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx]) min ans x-T[t_idx-1]*2+S[s_idx] x-T[t_idx-1]*2 x T[t_idx-1]*2 T[t_idx-1] T t_idx-1 t_idx 1 2 S[s_idx] S s_idx x-S[s_idx-1]*2+T[t_idx] x-S[s_idx-1]*2 x S[s_idx-1]*2 S[s_idx-1] S s_idx-1 s_idx 1 2 T[t_idx] T t_idx print(ans) print ans ans = max(S[0], T[0])-x max(S[0], T[0])-x ans ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1]) min(x-S[-1]*2+T[0], T[0]*2-x-S[-1]) ans A,B,Q = map(int, input().split()) map(int, input().split()) A B,Q = map(int, input().split()) map(int, input().split()) B Q = map(int, input().split()) map(int, input().split()) Q ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0]) min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0]) ans ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1]) min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1]) ans ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0]) min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0]) ans s_idx = bisect.bisect_left(S, x) bisect.bisect_left(S, x) s_idx ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx]) min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx]) ans T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T ans = x-min(S[-1], T[-1]) x-min(S[-1], T[-1]) ans t_idx = bisect.bisect_left(T, x) bisect.bisect_left(T, x) t_idx S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S x = int(input()) int(input()) x ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1]) min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1]) ans ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1]) min(x-T[-1]*2+S[0], S[0]*2-x-T[-1]) ans ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1]) min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1]) ans
A,B,Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
import bisect
for _ in range(Q):
    x = int(input())
    s_idx = bisect.bisect_left(S, x)
    t_idx = bisect.bisect_left(T, x)
    if s_idx == A and t_idx == B:
        ans = x-min(S[-1], T[-1])
    elif s_idx == A and t_idx == 0:
        ans = min(x-S[-1]*2+T[0], T[0]*2-x-S[-1])
    elif t_idx == B and s_idx == 0:
        ans = min(x-T[-1]*2+S[0], S[0]*2-x-T[-1])
    elif s_idx == A:
        ans = min(x-min(S[-1], T[t_idx-1]), x-S[-1]*2+T[t_idx], T[t_idx]*2-x-S[-1])
    elif t_idx == B:
        ans = min(x-min(T[-1], S[s_idx-1]), x-T[-1]*2+S[s_idx], S[s_idx]*2-x-T[-1])
    elif s_idx == 0 and t_idx == 0:
        ans = max(S[0], T[0])-x
    elif s_idx == 0:
        ans = min(max(S[0], T[t_idx])-x, S[0]*2-x-T[t_idx-1], x-T[t_idx-1]*2+S[0])
    elif t_idx == 0:
        ans = min(max(T[0], S[s_idx])-x, T[0]*2-x-S[s_idx-1], x-S[s_idx-1]*2+T[0])
    else:
        ans = min(max(S[s_idx], T[t_idx])-x, x-min(S[s_idx-1], T[t_idx-1]), S[s_idx]*2-x-T[t_idx-1], T[t_idx]*2-x-S[s_idx-1])
        ans = min(ans, x-T[t_idx-1]*2+S[s_idx], x-S[s_idx-1]*2+T[t_idx])
    print(ans)