from bisect import bisect_left
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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

    ans = []
    for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

    for a in ans:
        print(a)


if __name__ == "__main__":
    main() from bisect import bisect_left import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 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 def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    ans = []
    for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

    for a in ans:
        print(a) 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)] ans = [] ans [] for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

     _ range(Q) range Q x = int(input()) x int(input()) int input() input i = bisect_left(S, x) i bisect_left(S, x) bisect_left S x if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
         i == 0 i 0 s_left = None s_left None s_left = S[i - 1] s_left S[i - 1] S i - 1 i 1 if i < A:
            s_right = S[i]
        else:
            s_right = None

         i < A i A s_right = S[i] s_right S[i] S i s_right = None s_right None j = bisect_left(T, x) j bisect_left(T, x) bisect_left T x if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

         j == 0 j 0 t_left = None t_left None t_left = T[j - 1] t_left T[j - 1] T j - 1 j 1 if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
         j < B j B t_right = T[j] t_right T[j] T j t_right = None t_right None if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
         s_left is not None and t_left is not None s_left is not None s_left None t_left is not None t_left None ans1 = x - min(s_left, t_left) ans1 x - min(s_left, t_left) x min(s_left, t_left) min s_left t_left ans1 = INF ans1 INF if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
         s_right is not None and t_right is not None s_right is not None s_right None t_right is not None t_right None ans2 = max(s_right, t_right) - x ans2 max(s_right, t_right) - x max(s_right, t_right) max s_right t_right x ans2 = INF ans2 INF if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
         s_right is not None and t_left is not None s_right is not None s_right None t_left is not None t_left None ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left) ans3 min(s_right - x + s_right - t_left, x - t_left + s_right - t_left) min s_right - x + s_right - t_left s_right - x + s_right s_right - x s_right x s_right t_left x - t_left + s_right - t_left x - t_left + s_right x - t_left x t_left s_right t_left ans3 = INF ans3 INF if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

         t_right is not None and s_left is not None t_right is not None t_right None s_left is not None s_left None ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left) ans4 min(t_right - x + t_right - s_left, x - s_left + t_right - s_left) min t_right - x + t_right - s_left t_right - x + t_right t_right - x t_right x t_right s_left x - s_left + t_right - s_left x - s_left + t_right x - s_left x s_left t_right s_left ans4 = INF ans4 INF a = min(ans1, ans2, ans3, ans4) a min(ans1, ans2, ans3, ans4) min ans1 ans2 ans3 ans4 ans.append(a) ans.append ans append a for a in ans:
        print(a) a ans print(a) print a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main INF = float("inf") float("inf") INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]

    ans = []
    for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

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

    ans = []
    for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

    for a in ans:
        print(a) main def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
from bisect import bisect_left
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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

    ans = []
    for _ in range(Q):
        x = int(input())

        i = bisect_left(S, x)
        if i == 0:
            s_left = None
        else:
            s_left = S[i - 1]
        if i < A:
            s_right = S[i]
        else:
            s_right = None

        j = bisect_left(T, x)
        if j == 0:
            t_left = None
        else:
            t_left = T[j - 1]

        if j < B:
            t_right = T[j]
        else:
            t_right = None

        # 左にいきっぱなし
        if s_left is not None and t_left is not None:
            ans1 = x - min(s_left, t_left)
        else:
            ans1 = INF

        # みぎにいきっぱなし
        if s_right is not None and t_right is not None:
            ans2 = max(s_right, t_right) - x
        else:
            ans2 = INF

        # 右神社 左寺
        if s_right is not None and t_left is not None:
            ans3 = min(s_right - x + s_right - t_left, x - t_left + s_right - t_left)
        else:
            ans3 = INF

        # 右寺，左神社
        if t_right is not None and s_left is not None:
            ans4 = min(t_right - x + t_right - s_left, x - s_left + t_right - s_left)
        else:
            ans4 = INF

        a = min(ans1, ans2, ans3, ans4)
        ans.append(a)

    for a in ans:
        print(a)


if __name__ == "__main__":
    main()
