import bisect

A, B, Q = list(map(int,input().split()))

S = [int(eval(input())) for _ in range(A)]

T = [int(eval(input())) for _ in range(B)]

X = [int(eval(input())) for _ in range(Q)]

S.insert(0,-float("inf"))

S.append(float("inf"))

T.insert(0,-float("inf"))

T.append(float("inf"))

for i in range(Q):

  ans = float("inf")

  #shrine start

  plc_id = bisect.bisect_left(S,X[i])

  right = bisect.bisect_left(T,S[plc_id])

  left = bisect.bisect_left(T,S[plc_id-1])

  one = abs(X[i] - S[plc_id-1])

  two = abs(X[i] - S[plc_id])

  ans = min(ans,one + min(abs(S[plc_id-1] - T[left-1]),abs(S[plc_id-1]-T[left])))

  ans = min(ans,two + min(abs(S[plc_id] - T[right-1]),abs(S[plc_id]-T[right])))

  #temple start

  plc_id = bisect.bisect_left(T,X[i])

  right = bisect.bisect_left(S,T[plc_id])

  left = bisect.bisect_left(S,T[plc_id-1])

  one = abs(X[i] - T[plc_id-1])

  two = abs(X[i] - T[plc_id])

  ans = min(ans,one + min(abs(T[plc_id-1] - S[left-1]),abs(T[plc_id-1]-S[left])))

  ans = min(ans,two + min(abs(T[plc_id] - S[right-1]),abs(T[plc_id]-S[right])))

  print(ans)
def main():

  import bisect

  A, B, Q = list(map(int,input().split()))

  S = [int(eval(input())) for _ in range(A)]

  T = [int(eval(input())) for _ in range(B)]

  X = [int(eval(input())) for _ in range(Q)]

  S.insert(0,-float("inf"))

  S.append(float("inf"))

  T.insert(0,-float("inf"))

  T.append(float("inf"))

  for i in range(Q):

    ans = float("inf")

    #shrine start

    plc_id = bisect.bisect_left(S,X[i])

    right = bisect.bisect_left(T,S[plc_id])

    left = bisect.bisect_left(T,S[plc_id-1])

    left_d = abs(X[i] - S[plc_id-1])

    right_d = abs(X[i] - S[plc_id])

    ans = min(ans,left_d + min(abs(S[plc_id-1] - T[left-1]),abs(S[plc_id-1]-T[left])))

    ans = min(ans,right_d + min(abs(S[plc_id] - T[right-1]),abs(S[plc_id]-T[right])))

    #temple start

    plc_id = bisect.bisect_left(T,X[i])

    right = bisect.bisect_left(S,T[plc_id])

    left = bisect.bisect_left(S,T[plc_id-1])

    left_d = abs(X[i] - T[plc_id-1])

    right_d = abs(X[i] - T[plc_id])

    ans = min(ans,left_d + min(abs(T[plc_id-1] - S[left-1]),abs(T[plc_id-1]-S[left])))

    ans = min(ans,right_d + min(abs(T[plc_id] - S[right-1]),abs(T[plc_id]-S[right])))

    print(ans)

main()
import bisect

A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
X = [int(eval(input())) for _ in range(Q)]
S.insert(0, -float("inf"))
S.append(float("inf"))
T.insert(0, -float("inf"))
T.append(float("inf"))
for i in range(Q):
    ans = float("inf")
    # shrine start
    plc_id = bisect.bisect_left(S, X[i])
    right = bisect.bisect_left(T, S[plc_id])
    left = bisect.bisect_left(T, S[plc_id - 1])
    one = abs(X[i] - S[plc_id - 1])
    two = abs(X[i] - S[plc_id])
    ans = min(
        ans, one + min(abs(S[plc_id - 1] - T[left - 1]), abs(S[plc_id - 1] - T[left]))
    )
    ans = min(ans, two + min(abs(S[plc_id] - T[right - 1]), abs(S[plc_id] - T[right])))
    # temple start
    plc_id = bisect.bisect_left(T, X[i])
    right = bisect.bisect_left(S, T[plc_id])
    left = bisect.bisect_left(S, T[plc_id - 1])
    one = abs(X[i] - T[plc_id - 1])
    two = abs(X[i] - T[plc_id])
    ans = min(
        ans, one + min(abs(T[plc_id - 1] - S[left - 1]), abs(T[plc_id - 1] - S[left]))
    )
    ans = min(ans, two + min(abs(T[plc_id] - S[right - 1]), abs(T[plc_id] - S[right])))
    print(ans)

def main():
    import bisect

    A, B, Q = list(map(int, input().split()))
    S = [int(eval(input())) for _ in range(A)]
    T = [int(eval(input())) for _ in range(B)]
    X = [int(eval(input())) for _ in range(Q)]
    S.insert(0, -float("inf"))
    S.append(float("inf"))
    T.insert(0, -float("inf"))
    T.append(float("inf"))
    for i in range(Q):
        ans = float("inf")
        # shrine start
        plc_id = bisect.bisect_left(S, X[i])
        right = bisect.bisect_left(T, S[plc_id])
        left = bisect.bisect_left(T, S[plc_id - 1])
        left_d = abs(X[i] - S[plc_id - 1])
        right_d = abs(X[i] - S[plc_id])
        ans = min(
            ans,
            left_d
            + min(abs(S[plc_id - 1] - T[left - 1]), abs(S[plc_id - 1] - T[left])),
        )
        ans = min(
            ans, right_d + min(abs(S[plc_id] - T[right - 1]), abs(S[plc_id] - T[right]))
        )
        # temple start
        plc_id = bisect.bisect_left(T, X[i])
        right = bisect.bisect_left(S, T[plc_id])
        left = bisect.bisect_left(S, T[plc_id - 1])
        left_d = abs(X[i] - T[plc_id - 1])
        right_d = abs(X[i] - T[plc_id])
        ans = min(
            ans,
            left_d
            + min(abs(T[plc_id - 1] - S[left - 1]), abs(T[plc_id - 1] - S[left])),
        )
        ans = min(
            ans, right_d + min(abs(T[plc_id] - S[right - 1]), abs(T[plc_id] - S[right]))
        )
        print(ans)


main()

-import bisect +def main(): +    import bisect -A, B, Q = list(map(int, input().split())) -S = [int(eval(input())) for _ in range(A)] -T = [int(eval(input())) for _ in range(B)] -X = [int(eval(input())) for _ in range(Q)] -S.insert(0, -float("inf")) -S.append(float("inf")) -T.insert(0, -float("inf")) -T.append(float("inf")) -for i in range(Q): -    ans = float("inf") -    # shrine start -    plc_id = bisect.bisect_left(S, X[i]) -    right = bisect.bisect_left(T, S[plc_id]) -    left = bisect.bisect_left(T, S[plc_id - 1]) -    one = abs(X[i] - S[plc_id - 1]) -    two = abs(X[i] - S[plc_id]) -    ans = min( -        ans, one + min(abs(S[plc_id - 1] - T[left - 1]), abs(S[plc_id - 1] - T[left])) -    ) -    ans = min(ans, two + min(abs(S[plc_id] - T[right - 1]), abs(S[plc_id] - T[right]))) -    # temple start -    plc_id = bisect.bisect_left(T, X[i]) -    right = bisect.bisect_left(S, T[plc_id]) -    left = bisect.bisect_left(S, T[plc_id - 1]) -    one = abs(X[i] - T[plc_id - 1]) -    two = abs(X[i] - T[plc_id]) -    ans = min( -        ans, one + min(abs(T[plc_id - 1] - S[left - 1]), abs(T[plc_id - 1] - S[left])) -    ) -    ans = min(ans, two + min(abs(T[plc_id] - S[right - 1]), abs(T[plc_id] - S[right]))) -    print(ans) +    A, B, Q = list(map(int, input().split())) +    S = [int(eval(input())) for _ in range(A)] +    T = [int(eval(input())) for _ in range(B)] +    X = [int(eval(input())) for _ in range(Q)] +    S.insert(0, -float("inf")) +    S.append(float("inf")) +    T.insert(0, -float("inf")) +    T.append(float("inf")) +    for i in range(Q): +        ans = float("inf") +        # shrine start +        plc_id = bisect.bisect_left(S, X[i]) +        right = bisect.bisect_left(T, S[plc_id]) +        left = bisect.bisect_left(T, S[plc_id - 1]) +        left_d = abs(X[i] - S[plc_id - 1]) +        right_d = abs(X[i] - S[plc_id]) +        ans = min( +            ans, +            left_d +            + min(abs(S[plc_id - 1] - T[left - 1]), abs(S[plc_id - 1] - T[left])), +        ) +        ans = min( +            ans, right_d + min(abs(S[plc_id] - T[right - 1]), abs(S[plc_id] - T[right])) +        ) +        # temple start +        plc_id = bisect.bisect_left(T, X[i]) +        right = bisect.bisect_left(S, T[plc_id]) +        left = bisect.bisect_left(S, T[plc_id - 1]) +        left_d = abs(X[i] - T[plc_id - 1]) +        right_d = abs(X[i] - T[plc_id]) +        ans = min( +            ans, +            left_d +            + min(abs(T[plc_id - 1] - S[left - 1]), abs(T[plc_id - 1] - S[left])), +        ) +        ans = min( +            ans, right_d + min(abs(T[plc_id] - S[right - 1]), abs(T[plc_id] - S[right])) +        ) +        print(ans) + + +main()