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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

    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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

    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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

     i x enumerate(X) enumerate X i1 = bisect_left(S, x) i1 bisect_left(S, x) bisect_left S x i2 = bisect_left(T, x) i2 bisect_left(T, x) bisect_left T x ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        ) ans[i] ans i min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        ) min abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]) abs(x - S[i1 - 1]) abs x - S[i1 - 1] x S[i1 - 1] S i1 - 1 i1 1 abs(S[i1 - 1] - T[i2 - 1]) abs S[i1 - 1] - T[i2 - 1] S[i1 - 1] S i1 - 1 i1 1 T[i2 - 1] T i2 - 1 i2 1 abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]) abs(x - T[i2 - 1]) abs x - T[i2 - 1] x T[i2 - 1] T i2 - 1 i2 1 abs(T[i2 - 1] - S[i1 - 1]) abs T[i2 - 1] - S[i1 - 1] T[i2 - 1] T i2 - 1 i2 1 S[i1 - 1] S i1 - 1 i1 1 abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]) abs(x - S[i1 - 1]) abs x - S[i1 - 1] x S[i1 - 1] S i1 - 1 i1 1 abs(S[i1 - 1] - T[i2]) abs S[i1 - 1] - T[i2] S[i1 - 1] S i1 - 1 i1 1 T[i2] T i2 abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]) abs(x - T[i2 - 1]) abs x - T[i2 - 1] x T[i2 - 1] T i2 - 1 i2 1 abs(T[i2 - 1] - S[i1]) abs T[i2 - 1] - S[i1] T[i2 - 1] T i2 - 1 i2 1 S[i1] S i1 abs(x - S[i1]) + abs(S[i1] - T[i2]) abs(x - S[i1]) abs x - S[i1] x S[i1] S i1 abs(S[i1] - T[i2]) abs S[i1] - T[i2] S[i1] S i1 T[i2] T i2 abs(x - T[i2]) + abs(T[i2] - S[i1]) abs(x - T[i2]) abs x - T[i2] x T[i2] T i2 abs(T[i2] - S[i1]) abs T[i2] - S[i1] T[i2] T i2 S[i1] S i1 abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]) abs(x - S[i1]) abs x - S[i1] x S[i1] S i1 abs(S[i1] - T[i2 - 1]) abs S[i1] - T[i2 - 1] S[i1] S i1 T[i2 - 1] T i2 - 1 i2 1 abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]) abs(x - T[i2]) abs x - T[i2] x T[i2] T i2 abs(T[i2] - S[i1 - 1]) abs T[i2] - S[i1 - 1] T[i2] T i2 S[i1 - 1] S i1 - 1 i1 1 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 INF = 1 << 60 1 << 60 INF 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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

    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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

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

    return main readline = sys.stdin.readline sys.stdin.readline readline MOD = 1000000007 1000000007 MOD readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read
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):
        i1 = bisect_left(S, x)
        i2 = bisect_left(T, x)

        ans[i] = min(
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2 - 1]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1 - 1]),
            abs(x - S[i1 - 1]) + abs(S[i1 - 1] - T[i2]),
            abs(x - T[i2 - 1]) + abs(T[i2 - 1] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2]),
            abs(x - T[i2]) + abs(T[i2] - S[i1]),
            abs(x - S[i1]) + abs(S[i1] - T[i2 - 1]),
            abs(x - T[i2]) + abs(T[i2] - S[i1 - 1]),
        )

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

    return


if __name__ == '__main__':
    main()
