import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve() import sys sys from bisect import bisect_left def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0 solve input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 = [0] * Q Ans [0] * Q [0] 0 Q for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
     i range(Q) range Q x = int(input()) x int(input()) int input() input si, ti = bisect_left(S, x), bisect_left(T, x) si bisect_left(S, x) bisect_left S x ti bisect_left(T, x) bisect_left T x shortest_path = 10 ** 20 shortest_path 10 ** 20 10 20 if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
         si < A and ti < B si < A si A ti < B ti B if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
         si > 0 and ti > 0 si > 0 si 0 ti > 0 ti 0 if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
         si > 0 and ti < B si > 0 si 0 ti < B ti B if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
         ti > 0 and si < A ti > 0 ti 0 si < A si A Ans[i] = shortest_path Ans[i] Ans i shortest_path print("\n".join(map(str, Ans))) print "\n".join(map(str, Ans)) "\n".join "\n" join map(str, Ans) map str Ans return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0 def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0 solve
import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(input())
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10 ** 20
        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))
        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))
        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))
        Ans[i] = shortest_path
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()