from bisect import bisect_left, bisect, bisect_right
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]
start = [int(input()) for _ in range(q)]

for now_start in start:
    s_id = bisect_left(S, now_start)
    t_id = bisect_left(T, now_start)
    dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1]))
    dist2 = abs(now_start - max(S[s_id], T[t_id]))
    if max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1]:
        dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1])
    elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
    if min(S[s_id], T[t_id]) == S[s_id]:
        dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id])
    elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
    print(min(dist1, dist2, dist3, dist4)) from bisect import bisect_left, bisect, bisect_right 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 int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input start = [int(input()) for _ in range(q)] start [int(input()) for _ in range(q)] for now_start in start:
    s_id = bisect_left(S, now_start)
    t_id = bisect_left(T, now_start)
    dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1]))
    dist2 = abs(now_start - max(S[s_id], T[t_id]))
    if max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1]:
        dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1])
    elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
    if min(S[s_id], T[t_id]) == S[s_id]:
        dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id])
    elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
    print(min(dist1, dist2, dist3, dist4)) now_start start s_id = bisect_left(S, now_start) s_id bisect_left(S, now_start) bisect_left S now_start t_id = bisect_left(T, now_start) t_id bisect_left(T, now_start) bisect_left T now_start dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1])) dist1 abs(now_start - min(S[s_id - 1], T[t_id - 1])) abs now_start - min(S[s_id - 1], T[t_id - 1]) now_start min(S[s_id - 1], T[t_id - 1]) min S[s_id - 1] S s_id - 1 s_id 1 T[t_id - 1] T t_id - 1 t_id 1 dist2 = abs(now_start - max(S[s_id], T[t_id])) dist2 abs(now_start - max(S[s_id], T[t_id])) abs now_start - max(S[s_id], T[t_id]) now_start max(S[s_id], T[t_id]) max S[s_id] S s_id T[t_id] T t_id if max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1]:
        dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1])
    elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
     max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1] max(S[s_id - 1], T[t_id - 1]) max S[s_id - 1] S s_id - 1 s_id 1 T[t_id - 1] T t_id - 1 t_id 1 S[s_id - 1] S s_id - 1 s_id 1 dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1]) dist3 abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1]) abs(now_start - S[s_id - 1]) abs now_start - S[s_id - 1] now_start S[s_id - 1] S s_id - 1 s_id 1 abs(T[t_id] - S[s_id - 1]) abs T[t_id] - S[s_id - 1] T[t_id] T t_id S[s_id - 1] S s_id - 1 s_id 1 elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
     max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1] max(S[s_id - 1], T[t_id - 1]) max S[s_id - 1] S s_id - 1 s_id 1 T[t_id - 1] T t_id - 1 t_id 1 T[t_id - 1] T t_id - 1 t_id 1 dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1]) dist3 abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1]) abs(now_start - T[t_id - 1]) abs now_start - T[t_id - 1] now_start T[t_id - 1] T t_id - 1 t_id 1 abs(S[s_id] - T[t_id - 1]) abs S[s_id] - T[t_id - 1] S[s_id] S s_id T[t_id - 1] T t_id - 1 t_id 1 if min(S[s_id], T[t_id]) == S[s_id]:
        dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id])
    elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
     min(S[s_id], T[t_id]) == S[s_id] min(S[s_id], T[t_id]) min S[s_id] S s_id T[t_id] T t_id S[s_id] S s_id dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id]) dist4 abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id]) abs(now_start - S[s_id]) abs now_start - S[s_id] now_start S[s_id] S s_id abs(T[t_id - 1] - S[s_id]) abs T[t_id - 1] - S[s_id] T[t_id - 1] T t_id - 1 t_id 1 S[s_id] S s_id elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
     min(S[s_id], T[t_id]) == T[t_id] min(S[s_id], T[t_id]) min S[s_id] S s_id T[t_id] T t_id T[t_id] T t_id dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id]) dist4 abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id]) abs(now_start - T[t_id]) abs now_start - T[t_id] now_start T[t_id] T t_id abs(S[s_id - 1] - T[t_id]) abs S[s_id - 1] - T[t_id] S[s_id - 1] S s_id - 1 s_id 1 T[t_id] T t_id print(min(dist1, dist2, dist3, dist4)) print min(dist1, dist2, dist3, dist4) min dist1 dist2 dist3 dist4 T = [-INF] + [int(input()) for _ in range(b)] + [INF] [-INF] + [int(input()) for _ in range(b)] + [INF] T S = [-INF] + [int(input()) for _ in range(a)] + [INF] [-INF] + [int(input()) for _ in range(a)] + [INF] S dist2 = abs(now_start - max(S[s_id], T[t_id])) abs(now_start - max(S[s_id], T[t_id])) dist2 b, q = map(int, input().split()) map(int, input().split()) b s_id = bisect_left(S, now_start) bisect_left(S, now_start) s_id dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1]) abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1]) dist3 dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1])) abs(now_start - min(S[s_id - 1], T[t_id - 1])) dist1 start = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] start dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id]) abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id]) dist4 q = map(int, input().split()) map(int, input().split()) q dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1]) abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1]) dist3 a, b, q = map(int, input().split()) map(int, input().split()) a INF = 10 ** 18 10 ** 18 INF t_id = bisect_left(T, now_start) bisect_left(T, now_start) t_id dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id]) abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id]) dist4
from bisect import bisect_left, bisect, bisect_right
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]
start = [int(input()) for _ in range(q)]

for now_start in start:
    s_id = bisect_left(S, now_start)
    t_id = bisect_left(T, now_start)
    dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1]))
    dist2 = abs(now_start - max(S[s_id], T[t_id]))
    if max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1]:
        dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1])
    elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
    if min(S[s_id], T[t_id]) == S[s_id]:
        dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id])
    elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
    print(min(dist1, dist2, dist3, dist4))