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 = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

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

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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 = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

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

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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 int(readline()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(readline()) int readline() readline S = [int(readline()) for _ in range(A)] S [int(readline()) for _ in range(A)] int(readline()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(readline()) int readline() readline T = [int(readline()) for _ in range(B)] T [int(readline()) for _ in range(B)] 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 vs = [0] * 2 vs [0] * 2 [0] 0 2 vt = [0] * 2 vt [0] * 2 [0] 0 2 for i, x in enumerate(X):
        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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 vs[0] = S[idx_s - 1] if idx_s > 0 else -INF vs[0] vs 0 S[idx_s - 1] if idx_s > 0 else -INF idx_s > 0 idx_s 0 S[idx_s - 1] S idx_s - 1 idx_s 1 -INF INF vt[0] = T[idx_t - 1] if idx_t > 0 else -INF vt[0] vt 0 T[idx_t - 1] if idx_t > 0 else -INF idx_t > 0 idx_t 0 T[idx_t - 1] T idx_t - 1 idx_t 1 -INF INF vs[1] = S[idx_s] if idx_s < A else INF vs[1] vs 1 S[idx_s] if idx_s < A else INF idx_s < A idx_s A S[idx_s] S idx_s INF vt[1] = T[idx_t] if idx_t < B else INF vt[1] vt 1 T[idx_t] if idx_t < B else INF idx_t < B idx_t B T[idx_t] T idx_t INF for s in vs:
            for t in vt:
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

     s vs for t in vt:
                ans[i] = min(ans[i], abs(x - s) + abs(s - t), abs(x - t) + abs(t - s))

     t vt 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 def main():
    A, B, Q = map(int, readline().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

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

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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 = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

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

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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 readline = sys.stdin.readline sys.stdin.readline readline INF = 1 << 60 1 << 60 INF read = sys.stdin.read sys.stdin.read read readlines = sys.stdin.readlines sys.stdin.readlines readlines MOD = 1000000007 1000000007 MOD
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 = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]
    X = [int(readline()) for _ in range(Q)]

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

        vs[0] = S[idx_s - 1] if idx_s > 0 else -INF
        vt[0] = T[idx_t - 1] if idx_t > 0 else -INF
        vs[1] = S[idx_s] if idx_s < A else INF
        vt[1] = T[idx_t] if idx_t < B else INF

        for s in vs:
            for t in vt:
                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()
