from functools import lru_cache
from bisect import bisect
from sys import stdin
input = stdin.readline
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

@lru_cache(maxsize=None)
def func(f, x):
    L = S if f else T
    i = bisect(L, x)
    if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1]))

for x in [int(input()) for _ in range(Q)]:
    ans = float("inf")
    i = bisect(S, x)
    if i != 0:
        ans = min(ans, func(0, S[i - 1]) + x - S[i - 1])
    if i != A:
        ans = min(ans, func(0, S[i]) + S[i] - x)
    i = bisect(T, x)
    if i != 0:
        ans = min(ans, func(1, T[i - 1]) + x - T[i - 1])
    if i != B:
        ans = min(ans, func(1, T[i]) + T[i] - x)
    print(ans) from functools import lru_cache from bisect import bisect from sys import stdin input = stdin.readline input stdin.readline 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)] def func(f, x):
    L = S if f else T
    i = bisect(L, x)
    if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1])) func L = S if f else T L S if f else T f S T i = bisect(L, x) i bisect(L, x) bisect L x if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1])) i == 0 i 0 return abs(x - L[0]) abs(x - L[0]) abs x - L[0] x L[0] L 0 elif i == len(L):
        return abs(x - L[-1])
     i == len(L) i len(L) len L return abs(x - L[-1]) abs(x - L[-1]) abs x - L[-1] x L[-1] L -1 return min(abs(x - L[i]), abs(x - L[i - 1])) min(abs(x - L[i]), abs(x - L[i - 1])) min abs(x - L[i]) abs x - L[i] x L[i] L i abs(x - L[i - 1]) abs x - L[i - 1] x L[i - 1] L i - 1 i 1 f f x x @lru_cache(maxsize=None) func maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None func for x in [int(input()) for _ in range(Q)]:
    ans = float("inf")
    i = bisect(S, x)
    if i != 0:
        ans = min(ans, func(0, S[i - 1]) + x - S[i - 1])
    if i != A:
        ans = min(ans, func(0, S[i]) + S[i] - x)
    i = bisect(T, x)
    if i != 0:
        ans = min(ans, func(1, T[i - 1]) + x - T[i - 1])
    if i != B:
        ans = min(ans, func(1, T[i]) + T[i] - x)
    print(ans) x [int(input()) for _ in range(Q)] ans = float("inf") ans float("inf") float "inf" i = bisect(S, x) i bisect(S, x) bisect S x if i != 0:
        ans = min(ans, func(0, S[i - 1]) + x - S[i - 1])
     i != 0 i 0 ans = min(ans, func(0, S[i - 1]) + x - S[i - 1]) ans min(ans, func(0, S[i - 1]) + x - S[i - 1]) min ans func(0, S[i - 1]) + x - S[i - 1] func(0, S[i - 1]) + x func(0, S[i - 1]) func 0 S[i - 1] S i - 1 i 1 x S[i - 1] S i - 1 i 1 if i != A:
        ans = min(ans, func(0, S[i]) + S[i] - x)
     i != A i A ans = min(ans, func(0, S[i]) + S[i] - x) ans min(ans, func(0, S[i]) + S[i] - x) min ans func(0, S[i]) + S[i] - x func(0, S[i]) + S[i] func(0, S[i]) func 0 S[i] S i S[i] S i x i = bisect(T, x) i bisect(T, x) bisect T x if i != 0:
        ans = min(ans, func(1, T[i - 1]) + x - T[i - 1])
     i != 0 i 0 ans = min(ans, func(1, T[i - 1]) + x - T[i - 1]) ans min(ans, func(1, T[i - 1]) + x - T[i - 1]) min ans func(1, T[i - 1]) + x - T[i - 1] func(1, T[i - 1]) + x func(1, T[i - 1]) func 1 T[i - 1] T i - 1 i 1 x T[i - 1] T i - 1 i 1 if i != B:
        ans = min(ans, func(1, T[i]) + T[i] - x)
     i != B i B ans = min(ans, func(1, T[i]) + T[i] - x) ans min(ans, func(1, T[i]) + T[i] - x) min ans func(1, T[i]) + T[i] - x func(1, T[i]) + T[i] func(1, T[i]) func 1 T[i] T i T[i] T i x print(ans) print ans T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T ans = min(ans, func(0, S[i]) + S[i] - x) min(ans, func(0, S[i]) + S[i] - x) ans A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B ans = min(ans, func(0, S[i - 1]) + x - S[i - 1]) min(ans, func(0, S[i - 1]) + x - S[i - 1]) ans ans = min(ans, func(1, T[i - 1]) + x - T[i - 1]) min(ans, func(1, T[i - 1]) + x - T[i - 1]) ans ans = min(ans, func(1, T[i]) + T[i] - x) min(ans, func(1, T[i]) + T[i] - x) ans input = stdin.readline stdin.readline input i = bisect(T, x) bisect(T, x) i ans = float("inf") float("inf") ans S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S def func(f, x):
    L = S if f else T
    i = bisect(L, x)
    if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1])) def func(f, x):
    L = S if f else T
    i = bisect(L, x)
    if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1])) func i = bisect(S, x) bisect(S, x) i Q = map(int, input().split()) map(int, input().split()) Q
from functools import lru_cache
from bisect import bisect
from sys import stdin
input = stdin.readline
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

@lru_cache(maxsize=None)
def func(f, x):
    L = S if f else T
    i = bisect(L, x)
    if i == 0:
        return abs(x - L[0])
    elif i == len(L):
        return abs(x - L[-1])
    else:
        return min(abs(x - L[i]), abs(x - L[i - 1]))

for x in [int(input()) for _ in range(Q)]:
    ans = float("inf")
    i = bisect(S, x)
    if i != 0:
        ans = min(ans, func(0, S[i - 1]) + x - S[i - 1])
    if i != A:
        ans = min(ans, func(0, S[i]) + S[i] - x)
    i = bisect(T, x)
    if i != 0:
        ans = min(ans, func(1, T[i - 1]) + x - T[i - 1])
    if i != B:
        ans = min(ans, func(1, T[i]) + T[i] - x)
    print(ans)