import sys
def main():
    input = sys.stdin.readline
    A,B,Q=map(int, input().split())
    S=[int(input()) for _ in range(A)]
    T=[int(input()) for _ in range(B)]
    X=[int(input()) for _ in range(Q)]
    from bisect import bisect_left
    INF=10**11
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans)

if __name__ == '__main__':
    main() import sys sys def main():
    input = sys.stdin.readline
    A,B,Q=map(int, input().split())
    S=[int(input()) for _ in range(A)]
    T=[int(input()) for _ in range(B)]
    X=[int(input()) for _ in range(Q)]
    from bisect import bisect_left
    INF=10**11
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans) main input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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)] int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input X=[int(input()) for _ in range(Q)] X [int(input()) for _ in range(Q)] from bisect import bisect_left INF=10**11 INF 10**11 10 11 for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans) x X sr = bisect_left(S, x) sr bisect_left(S, x) bisect_left S x tr = bisect_left(T, x) tr bisect_left(T, x) bisect_left T x sl,tl=sr-1,tr-1 sl sr-1 sr 1 tl tr-1 tr 1 ans=INF ans INF if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
         sl >= 0 and tl >= 0 sl >= 0 sl 0 tl >= 0 tl 0 ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x))) ans min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x))) min ans abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)) abs(S[sl]-T[tl]) abs S[sl]-T[tl] S[sl] S sl T[tl] T tl min(abs(S[sl]-x), abs(T[tl]-x)) min abs(S[sl]-x) abs S[sl]-x S[sl] S sl x abs(T[tl]-x) abs T[tl]-x T[tl] T tl x if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
         sl >= 0 and tr < B sl >= 0 sl 0 tr < B tr B ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x))) ans min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x))) min ans abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)) abs(S[sl]-T[tr]) abs S[sl]-T[tr] S[sl] S sl T[tr] T tr min(abs(S[sl]-x), abs(T[tr]-x)) min abs(S[sl]-x) abs S[sl]-x S[sl] S sl x abs(T[tr]-x) abs T[tr]-x T[tr] T tr x if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
         sr < A and tl >= 0 sr < A sr A tl >= 0 tl 0 ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x))) ans min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x))) min ans abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)) abs(S[sr]-T[tl]) abs S[sr]-T[tl] S[sr] S sr T[tl] T tl min(abs(S[sr]-x), abs(T[tl]-x)) min abs(S[sr]-x) abs S[sr]-x S[sr] S sr x abs(T[tl]-x) abs T[tl]-x T[tl] T tl x if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
         sr < A and tr < B sr < A sr A tr < B tr B ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x))) ans min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x))) min ans abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)) abs(S[sr]-T[tr]) abs S[sr]-T[tr] S[sr] S sr T[tr] T tr min(abs(S[sr]-x), abs(T[tr]-x)) min abs(S[sr]-x) abs S[sr]-x S[sr] S sr x abs(T[tr]-x) abs T[tr]-x T[tr] T tr x print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    input = sys.stdin.readline
    A,B,Q=map(int, input().split())
    S=[int(input()) for _ in range(A)]
    T=[int(input()) for _ in range(B)]
    X=[int(input()) for _ in range(Q)]
    from bisect import bisect_left
    INF=10**11
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans) def main():
    input = sys.stdin.readline
    A,B,Q=map(int, input().split())
    S=[int(input()) for _ in range(A)]
    T=[int(input()) for _ in range(B)]
    X=[int(input()) for _ in range(Q)]
    from bisect import bisect_left
    INF=10**11
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans) main
import sys
def main():
    input = sys.stdin.readline
    A,B,Q=map(int, input().split())
    S=[int(input()) for _ in range(A)]
    T=[int(input()) for _ in range(B)]
    X=[int(input()) for _ in range(Q)]
    from bisect import bisect_left
    INF=10**11
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl,tl=sr-1,tr-1
        ans=INF
        if sl >= 0 and tl >= 0:
            ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))
        if sl >= 0 and tr < B:
            ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))
        if sr < A and tl >= 0:
            ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))
        if sr < A and tr < B:
            ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))
        print(ans)

if __name__ == '__main__':
    main()