import bisect
INF=10**11
A,B,q=map(int,input().split())
a=[-INF]+[int(input()) for _ in range(A)]+[INF]
b=[-INF]+[int(input()) for _ in range(B)]+[INF]
for _ in range(q):
  x=int(input())
  i=bisect.bisect_left(a,x)
  j=bisect.bisect_left(b,x)
  ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1]))
  print(ans) import bisect bisect INF=10**11 INF 10**11 10 11 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 a=[-INF]+[int(input()) for _ in range(A)]+[INF] a [-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 b=[-INF]+[int(input()) for _ in range(B)]+[INF] b [-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 _ in range(q):
  x=int(input())
  i=bisect.bisect_left(a,x)
  j=bisect.bisect_left(b,x)
  ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1]))
  print(ans) _ range(q) range q x=int(input()) x int(input()) int input() input i=bisect.bisect_left(a,x) i bisect.bisect_left(a,x) bisect.bisect_left bisect bisect_left a x j=bisect.bisect_left(b,x) j bisect.bisect_left(b,x) bisect.bisect_left bisect bisect_left b x ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1])) ans min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1])) min max(a[i],b[j])-x max(a[i],b[j]) max a[i] a i b[j] b j x x-min(a[i-1],b[j-1]) x min(a[i-1],b[j-1]) min a[i-1] a i-1 i 1 b[j-1] b j-1 j 1 a[i]-b[j-1]+min(a[i]-x,x-b[j-1]) a[i]-b[j-1] a[i] a i b[j-1] b j-1 j 1 min(a[i]-x,x-b[j-1]) min a[i]-x a[i] a i x x-b[j-1] x b[j-1] b j-1 j 1 b[j]-a[i-1]+min(b[j]-x,x-a[i-1]) b[j]-a[i-1] b[j] b j a[i-1] a i-1 i 1 min(b[j]-x,x-a[i-1]) min b[j]-x b[j] b j x x-a[i-1] x a[i-1] a i-1 i 1 print(ans) print ans x=int(input()) int(input()) x INF=10**11 10**11 INF A,B,q=map(int,input().split()) map(int,input().split()) A b=[-INF]+[int(input()) for _ in range(B)]+[INF] [-INF]+[int(input()) for _ in range(B)]+[INF] b ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1])) min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1])) ans a=[-INF]+[int(input()) for _ in range(A)]+[INF] [-INF]+[int(input()) for _ in range(A)]+[INF] a i=bisect.bisect_left(a,x) bisect.bisect_left(a,x) i j=bisect.bisect_left(b,x) bisect.bisect_left(b,x) j q=map(int,input().split()) map(int,input().split()) q B,q=map(int,input().split()) map(int,input().split()) B
import bisect
INF=10**11
A,B,q=map(int,input().split())
a=[-INF]+[int(input()) for _ in range(A)]+[INF]
b=[-INF]+[int(input()) for _ in range(B)]+[INF]
for _ in range(q):
  x=int(input())
  i=bisect.bisect_left(a,x)
  j=bisect.bisect_left(b,x)
  ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1]))
  print(ans)