import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect
def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0)))


if __name__=='__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input from bisect import bisect def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0))) main 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=[int(input())for _ in range(a)] S [int(input())for _ in range(a)] int(input())for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input T=[int(input())for _ in range(b)] T [int(input())for _ in range(b)] def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

     dfs if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

     flag2==1 flag2 1 index_s=bisect(S,cur) index_s bisect(S,cur) bisect S cur if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
         index_s>0 and index_s<a index_s>0 index_s 0 index_s<a index_s a if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
             flag1==0 flag1 0 return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur)) min(abs(S[index_s-1]-cur),abs(S[index_s]-cur)) min abs(S[index_s-1]-cur) abs S[index_s-1]-cur S[index_s-1] S index_s-1 index_s 1 cur abs(S[index_s]-cur) abs S[index_s]-cur S[index_s] S index_s cur return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur)) min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur)) min dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur) dfs(S[index_s-1],0,0) dfs S[index_s-1] S index_s-1 index_s 1 0 0 abs(S[index_s-1]-cur) abs S[index_s-1]-cur S[index_s-1] S index_s-1 index_s 1 cur dfs(S[index_s],0,0)+abs(S[index_s]-cur) dfs(S[index_s],0,0) dfs S[index_s] S index_s 0 0 abs(S[index_s]-cur) abs S[index_s]-cur S[index_s] S index_s cur if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                 index_s==a index_s a nx=S[-1] nx S[-1] S -1 elif index_s==0:
                    nx=S[0]
                 index_s==0 index_s 0 nx=S[0] nx S[0] S 0 if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
         flag1==1 flag1 1 return dfs(nx,0,0)+abs(nx-cur) dfs(nx,0,0)+abs(nx-cur) dfs(nx,0,0) dfs nx 0 0 abs(nx-cur) abs nx-cur nx cur return abs(nx-cur) abs(nx-cur) abs nx-cur nx cur index_t=bisect(T,cur) index_t bisect(T,cur) bisect T cur if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

     index_t>0 and index_t<b index_t>0 index_t 0 index_t<b index_t b if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
             flag1==0 flag1 0 return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur)) min(abs(T[index_t-1]-cur),abs(T[index_t]-cur)) min abs(T[index_t-1]-cur) abs T[index_t-1]-cur T[index_t-1] T index_t-1 index_t 1 cur abs(T[index_t]-cur) abs T[index_t]-cur T[index_t] T index_t cur return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur)) min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur)) min dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur) dfs(T[index_t-1],0,1) dfs T[index_t-1] T index_t-1 index_t 1 0 1 abs(T[index_t-1]-cur) abs T[index_t-1]-cur T[index_t-1] T index_t-1 index_t 1 cur dfs(T[index_t],0,1)+abs(T[index_t]-cur) dfs(T[index_t],0,1) dfs T[index_t] T index_t 0 1 abs(T[index_t]-cur) abs T[index_t]-cur T[index_t] T index_t cur if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                 index_t==b index_t b nx=T[-1] nx T[-1] T -1 elif index_t==0:
                    nx=T[0]
                 index_t==0 index_t 0 nx=T[0] nx T[0] T 0 if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

     flag1==1 flag1 1 return dfs(nx,0,1)+abs(nx-cur) dfs(nx,0,1)+abs(nx-cur) dfs(nx,0,1) dfs nx 0 1 abs(nx-cur) abs nx-cur nx cur return abs(nx-cur) abs(nx-cur) abs nx-cur nx cur cur cur flag1 flag1 flag2 flag2 for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0))) i range(q) range q x=int(input()) x int(input()) int input() input print(min(dfs(x,1,1),dfs(x,1,0))) print min(dfs(x,1,1),dfs(x,1,0)) min dfs(x,1,1) dfs x 1 1 dfs(x,1,0) dfs x 1 0 if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0))) def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0))) main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect
def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0)))


if __name__=='__main__':
    main()