import sys
from bisect import bisect_left


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer)


if __name__ == "__main__":
    main() import sys sys from bisect import bisect_left def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip sys.setrecursionlimit(20000000) sys.setrecursionlimit sys setrecursionlimit 20000000 def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer) main A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [int(input()) for _ in range(A)] S [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [int(input()) for _ in range(B)] T [int(input()) for _ in range(B)] for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer) i range(Q) range Q x = int(input()) x int(input()) int input() input s_index = bisect_left(S, x) s_index bisect_left(S, x) bisect_left S x if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

         s_index == 0 s_index 0 S1 = S[s_index] S1 S[s_index] S s_index S2 = S[s_index] S2 S[s_index] S s_index elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
         s_index == A s_index A S1 = S[s_index - 1] S1 S[s_index - 1] S s_index - 1 s_index 1 S2 = S[s_index - 1] S2 S[s_index - 1] S s_index - 1 s_index 1 S1 = S[s_index] S1 S[s_index] S s_index S2 = S[s_index - 1] S2 S[s_index - 1] S s_index - 1 s_index 1 t_index = bisect_left(T, x) t_index bisect_left(T, x) bisect_left T x if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
         t_index == 0 t_index 0 T1 = T[t_index] T1 T[t_index] T t_index T2 = T[t_index] T2 T[t_index] T t_index elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
         t_index == B t_index B T1 = T[t_index - 1] T1 T[t_index - 1] T t_index - 1 t_index 1 T2 = T[t_index - 1] T2 T[t_index - 1] T t_index - 1 t_index 1 T1 = T[t_index] T1 T[t_index] T t_index T2 = T[t_index - 1] T2 T[t_index - 1] T t_index - 1 t_index 1 answer = float("inf") answer float("inf") float "inf" for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
         s [S1, S2] S1 S2 for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
         t [T1, T2] T1 T2 r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s)) r min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s)) min abs(x - s) + abs(t - s) abs(x - s) abs x - s x s abs(t - s) abs t - s t s abs(x - t) + abs(t - s) abs(x - t) abs x - t x t abs(t - s) abs t - s t s if answer > r:
                    answer = r
         answer > r answer r answer = r answer r print(answer) print answer if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer) def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer) main def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys
from bisect import bisect_left


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    for i in range(Q):
        x = int(input())
        s_index = bisect_left(S, x)
        if s_index == 0:
            S1 = S[s_index]
            S2 = S[s_index]
        elif s_index == A:
            S1 = S[s_index - 1]
            S2 = S[s_index - 1]
        else:
            S1 = S[s_index]
            S2 = S[s_index - 1]

        t_index = bisect_left(T, x)
        if t_index == 0:
            T1 = T[t_index]
            T2 = T[t_index]
        elif t_index == B:
            T1 = T[t_index - 1]
            T2 = T[t_index - 1]
        else:
            T1 = T[t_index]
            T2 = T[t_index - 1]
        answer = float("inf")
        for s in [S1, S2]:
            for t in [T1, T2]:
                r = min(abs(x - s) + abs(t - s), abs(x - t) + abs(t - s))
                if answer > r:
                    answer = r
        print(answer)


if __name__ == "__main__":
    main()
