def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans)
if __name__=='__main__':
    main() def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans) main INF=10**11 INF 10**11 10 11 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 _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input S=[-INF]+[int(input()) for _ in range(a)]+[INF] S [-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 T=[-INF]+[int(input()) for _ in range(b)]+[INF] T [-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())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans) _ range(q) range q x=int(input()) x int(input()) int input() input s=bisect_left(S,x) s bisect_left(S,x) bisect_left S x t=bisect_left(T,x) t bisect_left(T,x) bisect_left T x ans=max(T[t],S[s])-x ans max(T[t],S[s])-x max(T[t],S[s]) max T[t] T t S[s] S s x ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1])) ans min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1])) min ans S[s]-T[t-1]+min(S[s]-x,x-T[t-1]) S[s]-T[t-1] S[s] S s T[t-1] T t-1 t 1 min(S[s]-x,x-T[t-1]) min S[s]-x S[s] S s x x-T[t-1] x T[t-1] T t-1 t 1 ans=min(ans,x-min(S[s-1],T[t-1])) ans min(ans,x-min(S[s-1],T[t-1])) min ans x-min(S[s-1],T[t-1]) x min(S[s-1],T[t-1]) min S[s-1] S s-1 s 1 T[t-1] T t-1 t 1 ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1])) ans min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1])) min ans T[t]-S[s-1]+min(T[t]-x,x-S[s-1]) T[t]-S[s-1] T[t] T t S[s-1] S s-1 s 1 min(T[t]-x,x-S[s-1]) min T[t]-x T[t] T t x x-S[s-1] x S[s-1] S s-1 s 1 print(ans) print ans if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans) def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans) main
def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans)
if __name__=='__main__':
    main()