from bisect import bisect_left
A, B, Q, *L = map(int, open(0).read().split())
s = L[:A]
t = L[A:A+B]
x = L[A+B:]

s = [-float('inf')]+s+[float('inf')]
t = [-float('inf')]+t+[float('inf')]
for c in x:
  br = bisect_left(t,c)
  ar = bisect_left(s,c)
  bl = br-1
  al = ar-1
  print(min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),
            c-min(t[bl],s[al]),max(s[ar],t[br])-c)) from bisect import bisect_left A, B, Q, *L = map(int, open(0).read().split()) A map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split B Q *L L s = L[:A] s L[:A] L :A A t = L[A:A+B] t L[A:A+B] L A:A+B A A+B A B x = L[A+B:] x L[A+B:] L A+B: A+B A B s = [-float('inf')]+s+[float('inf')] s [-float('inf')]+s+[float('inf')] [-float('inf')]+s [-float('inf')] -float('inf') float('inf') float 'inf' s [float('inf')] float('inf') float 'inf' t = [-float('inf')]+t+[float('inf')] t [-float('inf')]+t+[float('inf')] [-float('inf')]+t [-float('inf')] -float('inf') float('inf') float 'inf' t [float('inf')] float('inf') float 'inf' for c in x:
  br = bisect_left(t,c)
  ar = bisect_left(s,c)
  bl = br-1
  al = ar-1
  print(min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),
            c-min(t[bl],s[al]),max(s[ar],t[br])-c)) c x br = bisect_left(t,c) br bisect_left(t,c) bisect_left t c ar = bisect_left(s,c) ar bisect_left(s,c) bisect_left s c bl = br-1 bl br-1 br 1 al = ar-1 al ar-1 ar 1 print(min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),
            c-min(t[bl],s[al]),max(s[ar],t[br])-c)) print min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),
            c-min(t[bl],s[al]),max(s[ar],t[br])-c) min s[ar]-t[bl]+min(s[ar]-c,c-t[bl]) s[ar]-t[bl] s[ar] s ar t[bl] t bl min(s[ar]-c,c-t[bl]) min s[ar]-c s[ar] s ar c c-t[bl] c t[bl] t bl t[br]-s[al]+min(t[br]-c,c-s[al]) t[br]-s[al] t[br] t br s[al] s al min(t[br]-c,c-s[al]) min t[br]-c t[br] t br c c-s[al] c s[al] s al c-min(t[bl],s[al]) c min(t[bl],s[al]) min t[bl] t bl s[al] s al max(s[ar],t[br])-c max(s[ar],t[br]) max s[ar] s ar t[br] t br c t = L[A:A+B] L[A:A+B] t br = bisect_left(t,c) bisect_left(t,c) br Q, *L = map(int, open(0).read().split()) map(int, open(0).read().split()) Q t = [-float('inf')]+t+[float('inf')] [-float('inf')]+t+[float('inf')] t s = L[:A] L[:A] s al = ar-1 ar-1 al s = [-float('inf')]+s+[float('inf')] [-float('inf')]+s+[float('inf')] s ar = bisect_left(s,c) bisect_left(s,c) ar x = L[A+B:] L[A+B:] x A, B, Q, *L = map(int, open(0).read().split()) map(int, open(0).read().split()) A B, Q, *L = map(int, open(0).read().split()) map(int, open(0).read().split()) B bl = br-1 br-1 bl
from bisect import bisect_left
A, B, Q, *L = map(int, open(0).read().split())
s = L[:A]
t = L[A:A+B]
x = L[A+B:]

s = [-float('inf')]+s+[float('inf')]
t = [-float('inf')]+t+[float('inf')]
for c in x:
  br = bisect_left(t,c)
  ar = bisect_left(s,c)
  bl = br-1
  al = ar-1
  print(min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),
            c-min(t[bl],s[al]),max(s[ar],t[br])-c))