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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        ans[q] = min_dist
    return ans


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

    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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        ans[q] = min_dist
     q x enumerate(X) enumerate X min_dist = INF min_dist INF i = binary_search(S, x) i binary_search(S, x) binary_search S x if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
         0 < i 0 i l_s = S[i - 1] l_s S[i - 1] S i - 1 i 1 dist_s = abs(x - l_s) dist_s abs(x - l_s) abs x - l_s x l_s j = binary_search(T, l_s) j binary_search(T, l_s) binary_search T l_s l_t, r_t = T[j - 1], T[j] l_t T[j - 1] T j - 1 j 1 r_t T[j] T j dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s) dist_t min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s) 0 < j 0 j min(abs(l_s - l_t), abs(r_t - l_s)) min abs(l_s - l_t) abs l_s - l_t l_s l_t abs(r_t - l_s) abs r_t - l_s r_t l_s abs(r_t - l_s) abs r_t - l_s r_t l_s min_dist = min(min_dist, dist_s + dist_t) min_dist min(min_dist, dist_s + dist_t) min min_dist dist_s + dist_t dist_s dist_t r_s = S[i] r_s S[i] S i dist_s = abs(r_s - x) dist_s abs(r_s - x) abs r_s - x r_s x j = binary_search(T, r_s) j binary_search(T, r_s) binary_search T r_s l_t, r_t = T[j - 1], T[j] l_t T[j - 1] T j - 1 j 1 r_t T[j] T j dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s) dist_t min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s) 0 < j 0 j min(abs(r_s - l_t), abs(r_t - r_s)) min abs(r_s - l_t) abs r_s - l_t r_s l_t abs(r_t - r_s) abs r_t - r_s r_t r_s abs(r_t - r_s) abs r_t - r_s r_t r_s min_dist = min(min_dist, dist_s + dist_t) min_dist min(min_dist, dist_s + dist_t) min min_dist dist_s + dist_t dist_s dist_t i = binary_search(T, x) i binary_search(T, x) binary_search T x if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
         0 < i 0 i l_t = T[i - 1] l_t T[i - 1] T i - 1 i 1 dist_t = abs(l_t - x) dist_t abs(l_t - x) abs l_t - x l_t x j = binary_search(S, l_t) j binary_search(S, l_t) binary_search S l_t l_s, r_s = S[j - 1], S[j] l_s S[j - 1] S j - 1 j 1 r_s S[j] S j dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t) dist_s min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t) 0 < j 0 j min(abs(l_t - l_s), abs(r_s - l_t)) min abs(l_t - l_s) abs l_t - l_s l_t l_s abs(r_s - l_t) abs r_s - l_t r_s l_t abs(r_s - l_t) abs r_s - l_t r_s l_t min_dist = min(min_dist, dist_s + dist_t) min_dist min(min_dist, dist_s + dist_t) min min_dist dist_s + dist_t dist_s dist_t r_t = T[i] r_t T[i] T i dist_t = abs(r_t - x) dist_t abs(r_t - x) abs r_t - x r_t x j = binary_search(S, r_t) j binary_search(S, r_t) binary_search S r_t l_s, r_s = S[j - 1], S[j] l_s S[j - 1] S j - 1 j 1 r_s S[j] S j dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t) dist_s min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t) 0 < j 0 j min(abs(r_t - l_s), abs(r_s - r_t)) min abs(r_t - l_s) abs r_t - l_s r_t l_s abs(r_s - r_t) abs r_s - r_t r_s r_t abs(r_s - r_t) abs r_s - r_t r_s r_t min_dist = min(min_dist, dist_s + dist_t) min_dist min(min_dist, dist_s + dist_t) min min_dist dist_s + dist_t dist_s dist_t 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, dtype=np.int64)
    T = np.zeros(shape=B, dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    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, dtype=np.int64) S np.zeros(shape=A, dtype=np.int64) np.zeros np zeros shape=A shape A dtype=np.int64 dtype np.int64 np int64 T = np.zeros(shape=B, dtype=np.int64) T np.zeros(shape=B, dtype=np.int64) np.zeros np zeros shape=B shape B 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(A):
        S[i] = int(input())
     i range(A) range A S[i] = int(input()) S[i] S i int(input()) int input() input for i in range(B):
        T[i] = int(input())
     i range(B) range B 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 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 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 input = sys.stdin.readline sys.stdin.readline input def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=A, dtype=np.int64)
    T = np.zeros(shape=B, dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    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, dtype=np.int64)
    T = np.zeros(shape=B, dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans))) main 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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        ans[q] = min_dist
    return ans solve
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
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        ans[q] = min_dist
    return ans


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

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


if __name__ == "__main__":
    main()
