import bisect
def resolve():
    A, B, Q = list(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)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans)

def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res


if '__main__' == __name__:
    resolve() import bisect bisect def resolve():
    A, B, Q = list(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)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans) resolve A, B, Q = list(map(int, input().split())) A list(map(int, input().split())) list 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)] for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans) x X ans = float("inf") ans float("inf") float "inf" for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
         Ary1 Ary2 [[S, T], [T, S]] [S, T] S T [T, S] T S ar1_nearests = get_nearest_pos(Ary1, x) ar1_nearests get_nearest_pos(Ary1, x) get_nearest_pos Ary1 x for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
         p ar1_nearests ar2_nearests = get_nearest_pos(Ary2, p) ar2_nearests get_nearest_pos(Ary2, p) get_nearest_pos Ary2 p for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
         p2 ar2_nearests ans = min(ans, abs(x-p)+abs(p-p2)) ans min(ans, abs(x-p)+abs(p-p2)) min ans abs(x-p)+abs(p-p2) abs(x-p) abs x-p x p abs(p-p2) abs p-p2 p p2 print(ans) print ans def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res get_nearest_pos res = [] res [] idx = bisect.bisect_left(array, pos) idx bisect.bisect_left(array, pos) bisect.bisect_left bisect bisect_left array pos if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
     idx == 0 idx 0 res.append(array[idx]) res.append res append array[idx] array idx elif idx == len(array):
        res.append(array[idx-1])
     idx == len(array) idx len(array) len array res.append(array[idx-1]) res.append res append array[idx-1] array idx-1 idx 1 res.append(array[idx]) res.append res append array[idx] array idx res.append(array[idx-1]) res.append res append array[idx-1] array idx-1 idx 1 return res res array array pos pos if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def resolve():
    A, B, Q = list(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)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans) def resolve():
    A, B, Q = list(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)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans) resolve def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res get_nearest_pos
import bisect
def resolve():
    A, B, Q = list(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)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans)

def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res


if '__main__' == __name__:
    resolve()