import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, Q = map(int, readline().split())
    S = [-INF]
    S.extend(int(readline()) for _ in range(A))
    S.append(INF)
    T = [-INF]
    T.extend(int(readline()) for _ in range(B))
    T.append(INF)
    X = [int(readline()) for _ in range(Q)]

    ans = [INF] * Q
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

    print('\n'.join(map(str, ans)))

    return


if __name__ == '__main__':
    main() import sys sys from bisect import bisect_left read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    A, B, Q = map(int, readline().split())
    S = [-INF]
    S.extend(int(readline()) for _ in range(A))
    S.append(INF)
    T = [-INF]
    T.extend(int(readline()) for _ in range(B))
    T.append(INF)
    X = [int(readline()) for _ in range(Q)]

    ans = [INF] * Q
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

    print('\n'.join(map(str, ans)))

    return main A, B, Q = map(int, readline().split()) A map(int, readline().split()) map int readline().split() ().split () readline split B Q S = [-INF] S [-INF] -INF INF S.extend(int(readline()) for _ in range(A)) S.extend S extend int(readline()) int readline() readline S.append(INF) S.append S append INF T = [-INF] T [-INF] -INF INF T.extend(int(readline()) for _ in range(B)) T.extend T extend int(readline()) int readline() readline T.append(INF) T.append T append INF int(readline()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(readline()) int readline() readline X = [int(readline()) for _ in range(Q)] X [int(readline()) for _ in range(Q)] ans = [INF] * Q ans [INF] * Q [INF] INF Q for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

     i x enumerate(X) enumerate X idx_s = bisect_left(S, x) idx_s bisect_left(S, x) bisect_left S x idx_t = bisect_left(T, x) idx_t bisect_left(T, x) bisect_left T x for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

     s (S[idx_s - 1], S[idx_s]) S[idx_s - 1] S idx_s - 1 idx_s 1 S[idx_s] S idx_s for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

     t (T[idx_t - 1], T[idx_t]) T[idx_t - 1] T idx_t - 1 idx_t 1 T[idx_t] T idx_t ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s)) ans[i] ans i min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s)) min ans[i] ans i abs(x - s) + abs(s - t) abs(x - s) abs x - s x s abs(s - t) abs s - t s t abs(x - t) + abs(t - s) abs(x - t) abs x - t x t abs(t - s) abs t - s t s print('\n'.join(map(str, ans))) print '\n'.join(map(str, ans)) '\n'.join '\n' join map(str, ans) map str ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline MOD = 1000000007 1000000007 MOD def main():
    A, B, Q = map(int, readline().split())
    S = [-INF]
    S.extend(int(readline()) for _ in range(A))
    S.append(INF)
    T = [-INF]
    T.extend(int(readline()) for _ in range(B))
    T.append(INF)
    X = [int(readline()) for _ in range(Q)]

    ans = [INF] * Q
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

    print('\n'.join(map(str, ans)))

    return def main():
    A, B, Q = map(int, readline().split())
    S = [-INF]
    S.extend(int(readline()) for _ in range(A))
    S.append(INF)
    T = [-INF]
    T.extend(int(readline()) for _ in range(B))
    T.append(INF)
    X = [int(readline()) for _ in range(Q)]

    ans = [INF] * Q
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

    print('\n'.join(map(str, ans)))

    return main read = sys.stdin.read sys.stdin.read read INF = 1 << 60 1 << 60 INF readlines = sys.stdin.readlines sys.stdin.readlines readlines
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, Q = map(int, readline().split())
    S = [-INF]
    S.extend(int(readline()) for _ in range(A))
    S.append(INF)
    T = [-INF]
    T.extend(int(readline()) for _ in range(B))
    T.append(INF)
    X = [int(readline()) for _ in range(Q)]

    ans = [INF] * Q
    for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        for s in (S[idx_s - 1], S[idx_s]):
            for t in (T[idx_t - 1], T[idx_t]):
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

    print('\n'.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()
