import sys
from bisect import bisect_left

input = sys.stdin.readline


def solve(Q, S, T, X):
    ans = [0] * Q
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 = [0] * (A + 2)
    T = [0] * (B + 2)
    X = [0] * Q
    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 from bisect import bisect_left input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def solve(Q, S, T, X):
    ans = [0] * Q
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 = [0] * Q ans [0] * Q [0] 0 Q INF = 10 ** 11 INF 10 ** 11 10 11 for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 = bisect_left(S, x) i_s bisect_left(S, x) bisect_left S x i_t = bisect_left(T, x) i_t bisect_left(T, x) bisect_left 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 def main():
    A, B, Q = map(int, input().split())
    S = [0] * (A + 2)
    T = [0] * (B + 2)
    X = [0] * Q
    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 = [0] * (A + 2) S [0] * (A + 2) [0] 0 A + 2 A 2 T = [0] * (B + 2) T [0] * (B + 2) [0] 0 B + 2 B 2 X = [0] * Q X [0] * Q [0] 0 Q 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 solve(Q, S, T, X):
    ans = [0] * Q
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 = [0] * Q
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 input = sys.stdin.readline sys.stdin.readline input def main():
    A, B, Q = map(int, input().split())
    S = [0] * (A + 2)
    T = [0] * (B + 2)
    X = [0] * Q
    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 = [0] * (A + 2)
    T = [0] * (B + 2)
    X = [0] * Q
    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
import sys
from bisect import bisect_left

input = sys.stdin.readline


def solve(Q, S, T, X):
    ans = [0] * Q
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        i_s = bisect_left(S, x)
        i_t = bisect_left(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 = [0] * (A + 2)
    T = [0] * (B + 2)
    X = [0] * Q
    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()
