def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans)


if __name__ == "__main__":
    main() def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans) main from bisect import bisect_left A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q INF = 2 * 10 ** 10 INF 2 * 10 ** 10 2 10 ** 10 10 10 int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [-INF] + [int(input()) for _ in range(A)] + [INF] S [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] [-INF] -INF INF [int(input()) for _ in range(A)] [INF] INF int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [-INF] + [int(input()) for _ in range(B)] + [INF] T [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] [-INF] -INF INF [int(input()) for _ in range(B)] [INF] INF -s for s in S for s in S s S for s in S -s s S_rev = [-s for s in S][::-1] S_rev [-s for s in S][::-1] [-s for s in S] ::-1 -1 -t for t in T for t in T t T for t in T -t t T_rev = [-t for t in T][::-1] T_rev [-t for t in T][::-1] [-t for t in T] ::-1 -1 for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans) q range(Q) range Q x = int(input()) x int(input()) int input() input ans = 5 * 10 ** 10 ans 5 * 10 ** 10 5 10 ** 10 10 10 cost1_s = S[bisect_left(S, x)] - x cost1_s S[bisect_left(S, x)] - x S[bisect_left(S, x)] S bisect_left(S, x) bisect_left S x x cost1_t = T[bisect_left(T, x)] - x cost1_t T[bisect_left(T, x)] - x T[bisect_left(T, x)] T bisect_left(T, x) bisect_left T x x ans = min(ans, max(cost1_s, cost1_t)) ans min(ans, max(cost1_s, cost1_t)) min ans max(cost1_s, cost1_t) max cost1_s cost1_t cost2_s = S_rev[bisect_left(S_rev, -x)] + x cost2_s S_rev[bisect_left(S_rev, -x)] + x S_rev[bisect_left(S_rev, -x)] S_rev bisect_left(S_rev, -x) bisect_left S_rev -x x x cost2_t = T_rev[bisect_left(T_rev, -x)] + x cost2_t T_rev[bisect_left(T_rev, -x)] + x T_rev[bisect_left(T_rev, -x)] T_rev bisect_left(T_rev, -x) bisect_left T_rev -x x x ans = min(ans, max(cost2_s, cost2_t)) ans min(ans, max(cost2_s, cost2_t)) min ans max(cost2_s, cost2_t) max cost2_s cost2_t cost3_s = S[bisect_left(S, x)] - x cost3_s S[bisect_left(S, x)] - x S[bisect_left(S, x)] S bisect_left(S, x) bisect_left S x x cost3_t = T_rev[bisect_left(T_rev, -x)] + x cost3_t T_rev[bisect_left(T_rev, -x)] + x T_rev[bisect_left(T_rev, -x)] T_rev bisect_left(T_rev, -x) bisect_left T_rev -x x x ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t)) ans min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t)) min ans 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t) 2 * min(cost3_s, cost3_t) 2 min(cost3_s, cost3_t) min cost3_s cost3_t max(cost3_s, cost3_t) max cost3_s cost3_t cost3_s = S_rev[bisect_left(S_rev, -x)] + x cost3_s S_rev[bisect_left(S_rev, -x)] + x S_rev[bisect_left(S_rev, -x)] S_rev bisect_left(S_rev, -x) bisect_left S_rev -x x x cost3_t = T[bisect_left(T, x)] - x cost3_t T[bisect_left(T, x)] - x T[bisect_left(T, x)] T bisect_left(T, x) bisect_left T x x ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t)) ans min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t)) min ans 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t) 2 * min(cost3_s, cost3_t) 2 min(cost3_s, cost3_t) min cost3_s cost3_t max(cost3_s, cost3_t) max cost3_s cost3_t print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans) def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans) main
def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans)


if __name__ == "__main__":
    main()
