import bisect
INF=10**100

A,B,Q,*stx,=open(0).read().split()
A,B,Q=map(int,[A,B,Q])
slist=[-INF]+[int(stx[i]) for i in range(A)]+[INF]
tlist=[-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF]
xlist=[int(stx[i]) for i in range(A+B,A+B+Q)]
oslist=[0]*2
otlist=[0]*2
sr_index=0
tr_index=0
for i in xlist:
    ans=INF
    sr_index=bisect.bisect_left(slist,i)
    oslist=[slist[sr_index-1],slist[sr_index]]
    tr_index=bisect.bisect_left(tlist,i)
    otlist=[tlist[tr_index-1],tlist[tr_index]]
    for j in oslist:
        for k in otlist:
            ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k))
    print(ans) import bisect bisect INF=10**100 INF 10**100 10 100 A,B,Q,*stx,=open(0).read().split() A open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split B Q *stx stx A,B,Q=map(int,[A,B,Q]) A map(int,[A,B,Q]) map int [A,B,Q] A B Q B Q int(stx[i]) for i in range(A) for i in range(A) i range(A) range A for i in range(A) int(stx[i]) int stx[i] stx i slist=[-INF]+[int(stx[i]) for i in range(A)]+[INF] slist [-INF]+[int(stx[i]) for i in range(A)]+[INF] [-INF]+[int(stx[i]) for i in range(A)] [-INF] -INF INF [int(stx[i]) for i in range(A)] [INF] INF int(stx[i]) for i in range(A,A+B) for i in range(A,A+B) i range(A,A+B) range A A+B A B for i in range(A,A+B) int(stx[i]) int stx[i] stx i tlist=[-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF] tlist [-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF] [-INF]+[int(stx[i]) for i in range(A,A+B)] [-INF] -INF INF [int(stx[i]) for i in range(A,A+B)] [INF] INF int(stx[i]) for i in range(A+B,A+B+Q) for i in range(A+B,A+B+Q) i range(A+B,A+B+Q) range A+B A B A+B+Q A+B A B Q for i in range(A+B,A+B+Q) int(stx[i]) int stx[i] stx i xlist=[int(stx[i]) for i in range(A+B,A+B+Q)] xlist [int(stx[i]) for i in range(A+B,A+B+Q)] oslist=[0]*2 oslist [0]*2 [0] 0 2 otlist=[0]*2 otlist [0]*2 [0] 0 2 sr_index=0 sr_index 0 tr_index=0 tr_index 0 for i in xlist:
    ans=INF
    sr_index=bisect.bisect_left(slist,i)
    oslist=[slist[sr_index-1],slist[sr_index]]
    tr_index=bisect.bisect_left(tlist,i)
    otlist=[tlist[tr_index-1],tlist[tr_index]]
    for j in oslist:
        for k in otlist:
            ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k))
    print(ans) i xlist ans=INF ans INF sr_index=bisect.bisect_left(slist,i) sr_index bisect.bisect_left(slist,i) bisect.bisect_left bisect bisect_left slist i oslist=[slist[sr_index-1],slist[sr_index]] oslist [slist[sr_index-1],slist[sr_index]] slist[sr_index-1] slist sr_index-1 sr_index 1 slist[sr_index] slist sr_index tr_index=bisect.bisect_left(tlist,i) tr_index bisect.bisect_left(tlist,i) bisect.bisect_left bisect bisect_left tlist i otlist=[tlist[tr_index-1],tlist[tr_index]] otlist [tlist[tr_index-1],tlist[tr_index]] tlist[tr_index-1] tlist tr_index-1 tr_index 1 tlist[tr_index] tlist tr_index for j in oslist:
        for k in otlist:
            ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k))
     j oslist for k in otlist:
            ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k))
     k otlist ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k)) ans min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k)) min ans abs(j-i)+abs(k-j) abs(j-i) abs j-i j i abs(k-j) abs k-j k j abs(k-i)+abs(j-k) abs(k-i) abs k-i k i abs(j-k) abs j-k j k print(ans) print ans Q,*stx,=open(0).read().split() open(0).read().split() Q tr_index=0 0 tr_index otlist=[0]*2 [0]*2 otlist tlist=[-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF] [-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF] tlist sr_index=bisect.bisect_left(slist,i) bisect.bisect_left(slist,i) sr_index oslist=[0]*2 [0]*2 oslist ans=INF INF ans B,Q=map(int,[A,B,Q]) map(int,[A,B,Q]) B Q=map(int,[A,B,Q]) map(int,[A,B,Q]) Q xlist=[int(stx[i]) for i in range(A+B,A+B+Q)] [int(stx[i]) for i in range(A+B,A+B+Q)] xlist otlist=[tlist[tr_index-1],tlist[tr_index]] [tlist[tr_index-1],tlist[tr_index]] otlist B,Q,*stx,=open(0).read().split() open(0).read().split() B INF=10**100 10**100 INF A,B,Q,*stx,=open(0).read().split() open(0).read().split() A A,B,Q=map(int,[A,B,Q]) map(int,[A,B,Q]) A oslist=[slist[sr_index-1],slist[sr_index]] [slist[sr_index-1],slist[sr_index]] oslist tr_index=bisect.bisect_left(tlist,i) bisect.bisect_left(tlist,i) tr_index sr_index=0 0 sr_index slist=[-INF]+[int(stx[i]) for i in range(A)]+[INF] [-INF]+[int(stx[i]) for i in range(A)]+[INF] slist ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k)) min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k)) ans
import bisect
INF=10**100

A,B,Q,*stx,=open(0).read().split()
A,B,Q=map(int,[A,B,Q])
slist=[-INF]+[int(stx[i]) for i in range(A)]+[INF]
tlist=[-INF]+[int(stx[i]) for i in range(A,A+B)]+[INF]
xlist=[int(stx[i]) for i in range(A+B,A+B+Q)]
oslist=[0]*2
otlist=[0]*2
sr_index=0
tr_index=0
for i in xlist:
    ans=INF
    sr_index=bisect.bisect_left(slist,i)
    oslist=[slist[sr_index-1],slist[sr_index]]
    tr_index=bisect.bisect_left(tlist,i)
    otlist=[tlist[tr_index-1],tlist[tr_index]]
    for j in oslist:
        for k in otlist:
            ans=min(ans,abs(j-i)+abs(k-j),abs(k-i)+abs(j-k))
    print(ans)