import bisect
INF = 10**15
A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for i in range(Q):
  x = int(input())
  sw = bisect.bisect_right(s, x)-1 #xより西で一番近い(同じ場所でもいい)神社の番号
  se = sw + 1 #xより東で一番近い神社の番号
  tw = bisect.bisect_right(t, x)-1
  te = tw + 1
  res = INF
  for S in [s[sw], s[se]]:
    for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
  print(res)
 import bisect bisect INF = 10**15 INF 10**15 10 15 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 = [-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 for i in range(Q):
  x = int(input())
  sw = bisect.bisect_right(s, x)-1 #xより西で一番近い(同じ場所でもいい)神社の番号
  se = sw + 1 #xより東で一番近い神社の番号
  tw = bisect.bisect_right(t, x)-1
  te = tw + 1
  res = INF
  for S in [s[sw], s[se]]:
    for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
  print(res) i range(Q) range Q x = int(input()) x int(input()) int input() input sw = bisect.bisect_right(s, x)-1 sw bisect.bisect_right(s, x)-1 bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x 1 se = sw + 1 se sw + 1 sw 1 tw = bisect.bisect_right(t, x)-1 tw bisect.bisect_right(t, x)-1 bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x 1 te = tw + 1 te tw + 1 tw 1 res = INF res INF for S in [s[sw], s[se]]:
    for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
   S [s[sw], s[se]] s[sw] s sw s[se] s se for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
   T [t[tw], t[te]] t[tw] t tw t[te] t te d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T) d1 abs(x-S) + abs(T-S) abs(x-S) abs x-S x S abs(T-S) abs T-S T S d2 abs(x-T) + abs(S-T) abs(x-T) abs x-T x T abs(S-T) abs S-T S T res = min(res, d1, d2) res min(res, d1, d2) min res d1 d2 print(res) print res A, B, Q = map(int, input().split()) map(int, input().split()) A INF = 10**15 10**15 INF t = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] t d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T) abs(x-S) + abs(T-S) d1 d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T) abs(x-T) + abs(S-T) d2 sw = bisect.bisect_right(s, x)-1 bisect.bisect_right(s, x)-1 sw tw = bisect.bisect_right(t, x)-1 bisect.bisect_right(t, x)-1 tw B, Q = map(int, input().split()) map(int, input().split()) B te = tw + 1 tw + 1 te Q = map(int, input().split()) map(int, input().split()) Q x = int(input()) int(input()) x res = min(res, d1, d2) min(res, d1, d2) res res = INF INF res s = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] s se = sw + 1 sw + 1 se
import bisect
INF = 10**15
A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for i in range(Q):
  x = int(input())
  sw = bisect.bisect_right(s, x)-1 #xより西で一番近い(同じ場所でもいい)神社の番号
  se = sw + 1 #xより東で一番近い神社の番号
  tw = bisect.bisect_right(t, x)-1
  te = tw + 1
  res = INF
  for S in [s[sw], s[se]]:
    for T in [t[tw], t[te]]:
      d1, d2 = abs(x-S) + abs(T-S), abs(x-T) + abs(S-T)
      res = min(res, d1, d2)
  print(res)

