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 = [0] * 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

    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 = [0] * 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

    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 = [0] * Q ans [0] * Q [0] 0 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

     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 ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        ) ans[i] ans i min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        ) min abs(x - vs[0]) + abs(vs[0] - vt[0]) abs(x - vs[0]) abs x - vs[0] x vs[0] vs 0 abs(vs[0] - vt[0]) abs vs[0] - vt[0] vs[0] vs 0 vt[0] vt 0 abs(x - vt[0]) + abs(vt[0] - vs[0]) abs(x - vt[0]) abs x - vt[0] x vt[0] vt 0 abs(vt[0] - vs[0]) abs vt[0] - vs[0] vt[0] vt 0 vs[0] vs 0 abs(x - vs[0]) + abs(vs[0] - vt[1]) abs(x - vs[0]) abs x - vs[0] x vs[0] vs 0 abs(vs[0] - vt[1]) abs vs[0] - vt[1] vs[0] vs 0 vt[1] vt 1 abs(x - vt[0]) + abs(vt[0] - vs[1]) abs(x - vt[0]) abs x - vt[0] x vt[0] vt 0 abs(vt[0] - vs[1]) abs vt[0] - vs[1] vt[0] vt 0 vs[1] vs 1 abs(x - vs[1]) + abs(vs[1] - vt[1]) abs(x - vs[1]) abs x - vs[1] x vs[1] vs 1 abs(vs[1] - vt[1]) abs vs[1] - vt[1] vs[1] vs 1 vt[1] vt 1 abs(x - vt[1]) + abs(vt[1] - vs[1]) abs(x - vt[1]) abs x - vt[1] x vt[1] vt 1 abs(vt[1] - vs[1]) abs vt[1] - vs[1] vt[1] vt 1 vs[1] vs 1 abs(x - vs[1]) + abs(vs[1] - vt[0]) abs(x - vs[1]) abs x - vs[1] x vs[1] vs 1 abs(vs[1] - vt[0]) abs vs[1] - vt[0] vs[1] vs 1 vt[0] vt 0 abs(x - vt[1]) + abs(vt[1] - vs[0]) abs(x - vt[1]) abs x - vt[1] x vt[1] vt 1 abs(vt[1] - vs[0]) abs vt[1] - vs[0] vt[1] vt 1 vs[0] vs 0 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 = [0] * 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

    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 = [0] * 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

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

    return main MOD = 1000000007 1000000007 MOD readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read readline = sys.stdin.readline sys.stdin.readline readline INF = 1 << 60 1 << 60 INF
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 = [0] * 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

        ans[i] = min(
            abs(x - vs[0]) + abs(vs[0] - vt[0]),
            abs(x - vt[0]) + abs(vt[0] - vs[0]),
            abs(x - vs[0]) + abs(vs[0] - vt[1]),
            abs(x - vt[0]) + abs(vt[0] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[1]),
            abs(x - vt[1]) + abs(vt[1] - vs[1]),
            abs(x - vs[1]) + abs(vs[1] - vt[0]),
            abs(x - vt[1]) + abs(vt[1] - vs[0]),
        )

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

    return


if __name__ == '__main__':
    main()
