import itertools
from bisect import bisect_left
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
x=[int(input()) for i in range(Q)]

for i in range(Q):
    bs=bisect_left(s,x[i])
    bt=bisect_left(t,x[i])
    sli=[];bli=[]
    if(bs!=A):
        sli.append(s[bs])
    if(bs!=0):
        sli.append(s[bs-1])
    if(bt!=B):
        bli.append(t[bt])
    if(bt!=0):
        bli.append(t[bt-1])

    res=10**30
    for p in itertools.product(sli,bli):
        if(p[0]<=x[i] and p[1]<=x[i]):
            res=min(res,x[i]-min(p))
        elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
        else:
            res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2])
    print(res) import itertools itertools from bisect import bisect_left A,B,Q=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q int(input()) for i in range(A) for i in range(A) i range(A) range A for i in range(A) int(input()) int input() input s=[int(input()) for i in range(A)] s [int(input()) for i in range(A)] int(input()) for i in range(B) for i in range(B) i range(B) range B for i in range(B) int(input()) int input() input t=[int(input()) for i in range(B)] t [int(input()) for i in range(B)] int(input()) for i in range(Q) for i in range(Q) i range(Q) range Q for i in range(Q) int(input()) int input() input x=[int(input()) for i in range(Q)] x [int(input()) for i in range(Q)] for i in range(Q):
    bs=bisect_left(s,x[i])
    bt=bisect_left(t,x[i])
    sli=[];bli=[]
    if(bs!=A):
        sli.append(s[bs])
    if(bs!=0):
        sli.append(s[bs-1])
    if(bt!=B):
        bli.append(t[bt])
    if(bt!=0):
        bli.append(t[bt-1])

    res=10**30
    for p in itertools.product(sli,bli):
        if(p[0]<=x[i] and p[1]<=x[i]):
            res=min(res,x[i]-min(p))
        elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
        else:
            res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2])
    print(res) i range(Q) range Q bs=bisect_left(s,x[i]) bs bisect_left(s,x[i]) bisect_left s x[i] x i bt=bisect_left(t,x[i]) bt bisect_left(t,x[i]) bisect_left t x[i] x i sli=[] sli [] bli=[] bli [] if(bs!=A):
        sli.append(s[bs])
     bs!=A bs A sli.append(s[bs]) sli.append sli append s[bs] s bs if(bs!=0):
        sli.append(s[bs-1])
     bs!=0 bs 0 sli.append(s[bs-1]) sli.append sli append s[bs-1] s bs-1 bs 1 if(bt!=B):
        bli.append(t[bt])
     bt!=B bt B bli.append(t[bt]) bli.append bli append t[bt] t bt if(bt!=0):
        bli.append(t[bt-1])

     bt!=0 bt 0 bli.append(t[bt-1]) bli.append bli append t[bt-1] t bt-1 bt 1 res=10**30 res 10**30 10 30 for p in itertools.product(sli,bli):
        if(p[0]<=x[i] and p[1]<=x[i]):
            res=min(res,x[i]-min(p))
        elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
        else:
            res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2])
     p itertools.product(sli,bli) itertools.product itertools product sli bli if(p[0]<=x[i] and p[1]<=x[i]):
            res=min(res,x[i]-min(p))
        elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
        else:
            res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2])
     p[0]<=x[i] and p[1]<=x[i] p[0]<=x[i] p[0] p 0 x[i] x i p[1]<=x[i] p[1] p 1 x[i] x i res=min(res,x[i]-min(p)) res min(res,x[i]-min(p)) min res x[i]-min(p) x[i] x i min(p) min p elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
         p[0]>=x[i] and p[1]>=x[i] p[0]>=x[i] p[0] p 0 x[i] x i p[1]>=x[i] p[1] p 1 x[i] x i res=min(res,max(p)-x[i]) res min(res,max(p)-x[i]) min res max(p)-x[i] max(p) max p x[i] x i res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2]) res min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2]) min [res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2] res abs(p[1]-x[i])*2+abs(p[0]-x[i]) abs(p[1]-x[i])*2 abs(p[1]-x[i]) abs p[1]-x[i] p[1] p 1 x[i] x i 2 abs(p[0]-x[i]) abs p[0]-x[i] p[0] p 0 x[i] x i abs(p[1]-x[i])+abs(p[0]-x[i])*2 abs(p[1]-x[i]) abs p[1]-x[i] p[1] p 1 x[i] x i abs(p[0]-x[i])*2 abs(p[0]-x[i]) abs p[0]-x[i] p[0] p 0 x[i] x i 2 print(res) print res A,B,Q=map(int,input().split()) map(int,input().split()) A B,Q=map(int,input().split()) map(int,input().split()) B Q=map(int,input().split()) map(int,input().split()) Q res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2]) min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2]) res s=[int(input()) for i in range(A)] [int(input()) for i in range(A)] s res=min(res,x[i]-min(p)) min(res,x[i]-min(p)) res bt=bisect_left(t,x[i]) bisect_left(t,x[i]) bt bli=[] [] bli x=[int(input()) for i in range(Q)] [int(input()) for i in range(Q)] x sli=[] [] sli res=10**30 10**30 res t=[int(input()) for i in range(B)] [int(input()) for i in range(B)] t bs=bisect_left(s,x[i]) bisect_left(s,x[i]) bs res=min(res,max(p)-x[i]) min(res,max(p)-x[i]) res
import itertools
from bisect import bisect_left
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
x=[int(input()) for i in range(Q)]

for i in range(Q):
    bs=bisect_left(s,x[i])
    bt=bisect_left(t,x[i])
    sli=[];bli=[]
    if(bs!=A):
        sli.append(s[bs])
    if(bs!=0):
        sli.append(s[bs-1])
    if(bt!=B):
        bli.append(t[bt])
    if(bt!=0):
        bli.append(t[bt-1])

    res=10**30
    for p in itertools.product(sli,bli):
        if(p[0]<=x[i] and p[1]<=x[i]):
            res=min(res,x[i]-min(p))
        elif(p[0]>=x[i] and p[1]>=x[i]):
            res=min(res,max(p)-x[i])
        else:
            res=min([res,abs(p[1]-x[i])*2+abs(p[0]-x[i]),abs(p[1]-x[i])+abs(p[0]-x[i])*2])
    print(res)