import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8[:](i8,i8[:],i8[:],i8[:])", cache=True)
def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
    return ans


def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=(A + 2), dtype=np.int64)
    T = np.zeros(shape=(B + 2), dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(1, A + 1):
        S[i] = int(input())
    for i in range(1, B + 1):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    S[0] = T[0] = -10 ** 11
    S[-1] = T[-1] = 10 ** 11

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main() import sys sys import numba as nb numba import numpy as np numpy input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok binary_search """Meguru type binary search""" ng = -1 ng -1 ok = len(a) ok len(a) len a def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

     is_ok if key <= a[idx]:
            return True
        else:
            return False

     key <= a[idx] key a[idx] a idx return True True return False False a a key key idx idx while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

     abs(ok - ng) > 1 abs(ok - ng) abs ok - ng ok ng 1 mid = (ok + ng) // 2 mid (ok + ng) // 2 ok + ng ok ng 2 if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

     is_ok(a, key, mid) is_ok a key mid ok = mid ok mid ng = mid ng mid return ok ok a a key key @nb.njit("i8(i8[:],i8)", cache=True) binary_search "i8(i8[:],i8)", cache=True @nb.njit("i8(i8[:],i8)", cache=True) nb.njit "i8(i8[:],i8)" cache=True cache True binary_search def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
    return ans solve ans = np.zeros(shape=Q, dtype=np.int64) ans np.zeros(shape=Q, dtype=np.int64) np.zeros np zeros shape=Q shape Q dtype=np.int64 dtype np.int64 np int64 INF = 10 ** 11 INF 10 ** 11 10 11 for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
     q x enumerate(X) enumerate X min_dist = INF min_dist INF i_s = binary_search(S, x) i_s binary_search(S, x) binary_search S x i_t = binary_search(T, x) i_t binary_search(T, x) binary_search T x for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
         s (S[i_s - 1], S[i_s]) S[i_s - 1] S i_s - 1 i_s 1 S[i_s] S i_s for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
         t (T[i_t - 1], T[i_t]) T[i_t - 1] T i_t - 1 i_t 1 T[i_t] T i_t dist_s2t = abs(x - s) + abs(s - t) dist_s2t abs(x - s) + abs(s - t) abs(x - s) abs x - s x s abs(s - t) abs s - t s t dist_t2s = abs(x - t) + abs(t - s) dist_t2s abs(x - t) + abs(t - s) abs(x - t) abs x - t x t abs(t - s) abs t - s t s min_dist = min(min_dist, dist_s2t, dist_t2s) min_dist min(min_dist, dist_s2t, dist_t2s) min min_dist dist_s2t dist_t2s ans[q] = min_dist ans[q] ans q min_dist return ans ans Q Q S S T T X X @nb.njit("i8[:](i8,i8[:],i8[:],i8[:])", cache=True) solve "i8[:](i8,i8[:],i8[:],i8[:])", cache=True @nb.njit("i8[:](i8,i8[:],i8[:],i8[:])", cache=True) nb.njit "i8[:](i8,i8[:],i8[:],i8[:])" cache=True cache True solve def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=(A + 2), dtype=np.int64)
    T = np.zeros(shape=(B + 2), dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(1, A + 1):
        S[i] = int(input())
    for i in range(1, B + 1):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    S[0] = T[0] = -10 ** 11
    S[-1] = T[-1] = 10 ** 11

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans))) main A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q S = np.zeros(shape=(A + 2), dtype=np.int64) S np.zeros(shape=(A + 2), dtype=np.int64) np.zeros np zeros shape=(A + 2) shape A + 2 A 2 dtype=np.int64 dtype np.int64 np int64 T = np.zeros(shape=(B + 2), dtype=np.int64) T np.zeros(shape=(B + 2), dtype=np.int64) np.zeros np zeros shape=(B + 2) shape B + 2 B 2 dtype=np.int64 dtype np.int64 np int64 X = np.zeros(shape=Q, dtype=np.int64) X np.zeros(shape=Q, dtype=np.int64) np.zeros np zeros shape=Q shape Q dtype=np.int64 dtype np.int64 np int64 for i in range(1, A + 1):
        S[i] = int(input())
     i range(1, A + 1) range 1 A + 1 A 1 S[i] = int(input()) S[i] S i int(input()) int input() input for i in range(1, B + 1):
        T[i] = int(input())
     i range(1, B + 1) range 1 B + 1 B 1 T[i] = int(input()) T[i] T i int(input()) int input() input for i in range(Q):
        X[i] = int(input())

     i range(Q) range Q X[i] = int(input()) X[i] X i int(input()) int input() input S[0] = T[0] = -10 ** 11 S[0] S 0 -10 ** 11 -10 11 = T[0] = -10 ** 11 T[0] T 0 -10 ** 11 S[-1] = T[-1] = 10 ** 11 S[-1] S -1 10 ** 11 10 11 = T[-1] = 10 ** 11 T[-1] T -1 10 ** 11 ans = solve(Q, S, T, X) ans solve(Q, S, T, X) solve Q S T X print("\n".join(map(str, ans))) print "\n".join(map(str, ans)) "\n".join "\n" join map(str, ans) map str ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=(A + 2), dtype=np.int64)
    T = np.zeros(shape=(B + 2), dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(1, A + 1):
        S[i] = int(input())
    for i in range(1, B + 1):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    S[0] = T[0] = -10 ** 11
    S[-1] = T[-1] = 10 ** 11

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans))) def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=(A + 2), dtype=np.int64)
    T = np.zeros(shape=(B + 2), dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(1, A + 1):
        S[i] = int(input())
    for i in range(1, B + 1):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    S[0] = T[0] = -10 ** 11
    S[-1] = T[-1] = 10 ** 11

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans))) main input = sys.stdin.readline sys.stdin.readline input def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
    return ans def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
    return ans solve def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok binary_search
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8[:](i8,i8[:],i8[:],i8[:])", cache=True)
def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = binary_search(S, x)
        i_t = binary_search(T, x)
        for s in (S[i_s - 1], S[i_s]):
            for t in (T[i_t - 1], T[i_t]):
                dist_s2t = abs(x - s) + abs(s - t)
                dist_t2s = abs(x - t) + abs(t - s)
                min_dist = min(min_dist, dist_s2t, dist_t2s)
        ans[q] = min_dist
    return ans


def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=(A + 2), dtype=np.int64)
    T = np.zeros(shape=(B + 2), dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(1, A + 1):
        S[i] = int(input())
    for i in range(1, B + 1):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    S[0] = T[0] = -10 ** 11
    S[-1] = T[-1] = 10 ** 11

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()
