from bisect import bisect, bisect_left 

A, B, Q = map(int, input().split())
S, T, X = [0]*(A+2), [0]*(B+2), [0]*Q

INF = 10**10
S[0], T[0] = -INF, -INF
S[-1], T[-1] = 2*INF, 2*INF

for i in range(A):
  S[i+1] = int(input())

for i in range(B):
  T[i+1] = int(input())

for i in range(Q):
  X[i] = int(input())

def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans)

for x in X:
  print(dis(x)) from bisect import bisect, bisect_left A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q S, T, X = [0]*(A+2), [0]*(B+2), [0]*Q S [0]*(A+2) [0] 0 A+2 A 2 T [0]*(B+2) [0] 0 B+2 B 2 X [0]*Q [0] 0 Q INF = 10**10 INF 10**10 10 10 S[0], T[0] = -INF, -INF S[0] S 0 -INF INF T[0] T 0 -INF INF S[-1], T[-1] = 2*INF, 2*INF S[-1] S -1 2*INF 2 INF T[-1] T -1 2*INF 2 INF for i in range(A):
  S[i+1] = int(input()) i range(A) range A S[i+1] = int(input()) S[i+1] S i+1 i 1 int(input()) int input() input for i in range(B):
  T[i+1] = int(input()) i range(B) range B T[i+1] = int(input()) T[i+1] T i+1 i 1 int(input()) int input() input for i in range(Q):
  X[i] = int(input()) i range(Q) range Q X[i] = int(input()) X[i] X i int(input()) int input() input def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans) dis RS = bisect_left(S, x) RS bisect_left(S, x) bisect_left S x LS = RS - 1 LS RS - 1 RS 1 RT = bisect_left(T, x) RT bisect_left(T, x) bisect_left T x LT = RT - 1 LT RT - 1 RT 1 ans = [0]*4 ans [0]*4 [0] 0 4 ans[0] = max(S[RS], T[RT]) - x ans[0] ans 0 max(S[RS], T[RT]) - x max(S[RS], T[RT]) max S[RS] S RS T[RT] T RT x ans[1] = x - min(S[LS], T[LT]) ans[1] ans 1 x - min(S[LS], T[LT]) x min(S[LS], T[LT]) min S[LS] S LS T[LT] T LT ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT]) ans[2] ans 2 S[RS] - T[LT] + min(S[RS] - x, x - T[LT]) S[RS] - T[LT] S[RS] S RS T[LT] T LT min(S[RS] - x, x - T[LT]) min S[RS] - x S[RS] S RS x x - T[LT] x T[LT] T LT ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS]) ans[3] ans 3 T[RT] - S[LS] + min(T[RT] - x, x - S[LS]) T[RT] - S[LS] T[RT] T RT S[LS] S LS min(T[RT] - x, x - S[LS]) min T[RT] - x T[RT] T RT x x - S[LS] x S[LS] S LS return min(ans) min(ans) min ans x x for x in X:
  print(dis(x)) x X print(dis(x)) print dis(x) dis x Q = map(int, input().split()) map(int, input().split()) Q A, B, Q = map(int, input().split()) map(int, input().split()) A INF = 10**10 10**10 INF T, X = [0]*(A+2), [0]*(B+2), [0]*Q [0]*(B+2) T def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans) def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans) dis B, Q = map(int, input().split()) map(int, input().split()) B X = [0]*(A+2), [0]*(B+2), [0]*Q [0]*Q X S, T, X = [0]*(A+2), [0]*(B+2), [0]*Q [0]*(A+2) S
from bisect import bisect, bisect_left 

A, B, Q = map(int, input().split())
S, T, X = [0]*(A+2), [0]*(B+2), [0]*Q

INF = 10**10
S[0], T[0] = -INF, -INF
S[-1], T[-1] = 2*INF, 2*INF

for i in range(A):
  S[i+1] = int(input())

for i in range(B):
  T[i+1] = int(input())

for i in range(Q):
  X[i] = int(input())

def dis(x):
  RS = bisect_left(S, x)
  LS = RS - 1
  RT = bisect_left(T, x)
  LT = RT - 1
  ans = [0]*4
  ans[0] = max(S[RS], T[RT]) - x
  ans[1] = x - min(S[LS], T[LT])
  ans[2] = S[RS] - T[LT] + min(S[RS] - x, x - T[LT])
  ans[3] = T[RT] - S[LS] + min(T[RT] - x, x - S[LS])
  return min(ans)

for x in X:
  print(dis(x))