import bisect
import itertools

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

INF = float('inf')
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result

for x in X:
  ans = solve(x)
  print(ans) import bisect bisect import itertools itertools A,B,Q = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q INF = float('inf') INF float('inf') float 'inf' 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 int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input X = [int(input()) for _ in range(Q)] X [int(input()) for _ in range(Q)] def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result solve i = bisect.bisect_left(S, x) i bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x j = bisect.bisect_left(T, x) j bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x result = INF result INF for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
   s t itertools.product(S[i-1:i+1], T[j-1:j+1]) itertools.product itertools product S[i-1:i+1] S i-1:i+1 i-1 i 1 i+1 i 1 T[j-1:j+1] T j-1:j+1 j-1 j 1 j+1 j 1 d = min(abs(s-x),abs(t-x)) + abs(t-s) d min(abs(s-x),abs(t-x)) + abs(t-s) min(abs(s-x),abs(t-x)) min abs(s-x) abs s-x s x abs(t-x) abs t-x t x abs(t-s) abs t-s t s result = min(result,d) result min(result,d) min result d return result result x x for x in X:
  ans = solve(x)
  print(ans) x X ans = solve(x) ans solve(x) solve x print(ans) print ans X = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] X ans = solve(x) solve(x) ans B,Q = map(int,input().split()) map(int,input().split()) B INF = float('inf') float('inf') INF Q = map(int,input().split()) map(int,input().split()) Q T = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] T A,B,Q = map(int,input().split()) map(int,input().split()) A def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result solve S = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] S
import bisect
import itertools

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

INF = float('inf')
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

def solve(x):
  i = bisect.bisect_left(S, x)
  j = bisect.bisect_left(T, x)
  result = INF
  # どの2つを目指すか
  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):
    d = min(abs(s-x),abs(t-x)) + abs(t-s) # tがsとxの間に入るか否か
    result = min(result,d)
  return result

for x in X:
  ans = solve(x)
  print(ans)
