from bisect import bisect_right, bisect_left
A, B, Q = map(int, input().split())
INF = 10**18

S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]

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

    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1]
    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)]

    ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    )

    print(ans) from bisect import bisect_right, bisect_left A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q INF = 10**18 INF 10**18 10 18 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 for _ in range(Q):
    x = int(input())

    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1]
    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)]

    ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    )

    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1] lS S[bisect_right(S, x) - 1] S bisect_right(S, x) - 1 bisect_right(S, x) bisect_right S x 1 lT T[bisect_right(T, x) - 1] T bisect_right(T, x) - 1 bisect_right(T, x) bisect_right T x 1 rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)] rS S[bisect_left(S, x)] S bisect_left(S, x) bisect_left S x rT T[bisect_left(T, x)] T bisect_left(T, x) bisect_left T x ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    ) ans min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    ) min abs(lS - lT) + (x - max(lS, lT)) abs(lS - lT) abs lS - lT lS lT x - max(lS, lT) x max(lS, lT) max lS lT abs(rS - rT) + (min(rS, rT) - x) abs(rS - rT) abs rS - rT rS rT min(rS, rT) - x min(rS, rT) min rS rT x (rT - lS) + min(x - lS, rT - x) rT - lS rT lS min(x - lS, rT - x) min x - lS x lS rT - x rT x (rS - lT) + min(x - lT, rS - x) rS - lT rS lT min(x - lT, rS - x) min x - lT x lT rS - x rS x print(ans) print ans B, Q = map(int, input().split()) map(int, input().split()) B lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1] S[bisect_right(S, x) - 1] lS rT = S[bisect_left(S, x)], T[bisect_left(T, x)] T[bisect_left(T, x)] rT INF = 10**18 10**18 INF S = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] S T = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] T A, B, Q = map(int, input().split()) map(int, input().split()) A Q = map(int, input().split()) map(int, input().split()) Q x = int(input()) int(input()) x rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)] S[bisect_left(S, x)] rS lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1] T[bisect_right(T, x) - 1] lT ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    ) min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    ) ans
from bisect import bisect_right, bisect_left
A, B, Q = map(int, input().split())
INF = 10**18

S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]

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

    lS, lT = S[bisect_right(S, x) - 1], T[bisect_right(T, x) - 1]
    rS, rT = S[bisect_left(S, x)], T[bisect_left(T, x)]

    ans = min(
        abs(lS - lT) + (x - max(lS, lT)),
        abs(rS - rT) + (min(rS, rT) - x),
        (rT - lS) + min(x - lS, rT - x),
        (rS - lT) + min(x - lT, rS - x)
    )

    print(ans)
