import bisect



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

INF = 10 ** 11

s_list = [-INF] + [int(eval(input())) for i in range(A)] + [INF]

t_list = [-INF] + [int(eval(input())) for i in range(B)] + [INF]

for q in range(Q):

    x = int(eval(input()))

    near_right_s = bisect.bisect_right(s_list, x)

    near_right_t = bisect.bisect_right(t_list, x)

    min_distance = INF

    for s in [s_list[near_right_s - 1], s_list[near_right_s]]:

        for t in [t_list[near_right_t - 1], t_list[near_right_t]]:

            distance_1 = abs(s - x) + abs(t - s)

            distance_2 = abs(t - x) + abs(s - t)

            min_distance = min(min_distance, distance_1, distance_2)

    print(min_distance)
from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))

from bisect import bisect



a,b,q=nii()

s=[-10**18]+[int(eval(input())) for i in range(a)]+[10**18]

t=[-10**18]+[int(eval(input())) for i in range(b)]+[10**18]



for i in range(q):

  x=int(eval(input()))

  s_inx=bisect(s,x)

  t_inx=bisect(t,x)



  s_l=s[s_inx-1]

  s_r=s[s_inx]



  t_l=t[t_inx-1]

  t_r=t[t_inx]



  ans=10**18

  for i in [s_l,s_r]:

    for j in [t_l,t_r]:

      ans=min(ans,abs(i-x)+abs(j-i))



  for i in [t_l,t_r]:

    for j in [s_l,s_r]:

      ans=min(ans,abs(i-x)+abs(j-i))



  print(ans)
import bisect

A, B, Q = list(map(int, input().split()))
INF = 10**11
s_list = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t_list = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
    x = int(eval(input()))
    near_right_s = bisect.bisect_right(s_list, x)
    near_right_t = bisect.bisect_right(t_list, x)
    min_distance = INF
    for s in [s_list[near_right_s - 1], s_list[near_right_s]]:
        for t in [t_list[near_right_t - 1], t_list[near_right_t]]:
            distance_1 = abs(s - x) + abs(t - s)
            distance_2 = abs(t - x) + abs(s - t)
            min_distance = min(min_distance, distance_1, distance_2)
    print(min_distance)

from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from bisect import bisect

a, b, q = nii()
s = [-(10**18)] + [int(eval(input())) for i in range(a)] + [10**18]
t = [-(10**18)] + [int(eval(input())) for i in range(b)] + [10**18]
for i in range(q):
    x = int(eval(input()))
    s_inx = bisect(s, x)
    t_inx = bisect(t, x)
    s_l = s[s_inx - 1]
    s_r = s[s_inx]
    t_l = t[t_inx - 1]
    t_r = t[t_inx]
    ans = 10**18
    for i in [s_l, s_r]:
        for j in [t_l, t_r]:
            ans = min(ans, abs(i - x) + abs(j - i))
    for i in [t_l, t_r]:
        for j in [s_l, s_r]:
            ans = min(ans, abs(i - x) + abs(j - i))
    print(ans)

-import bisect +from sys import stdin -A, B, Q = list(map(int, input().split())) -INF = 10**11 -s_list = [-INF] + [int(eval(input())) for i in range(A)] + [INF] -t_list = [-INF] + [int(eval(input())) for i in range(B)] + [INF] -for q in range(Q): +nii = lambda: list(map(int, stdin.readline().split())) +lnii = lambda: list(map(int, stdin.readline().split())) +from bisect import bisect + +a, b, q = nii() +s = [-(10**18)] + [int(eval(input())) for i in range(a)] + [10**18] +t = [-(10**18)] + [int(eval(input())) for i in range(b)] + [10**18] +for i in range(q): -    near_right_s = bisect.bisect_right(s_list, x) -    near_right_t = bisect.bisect_right(t_list, x) -    min_distance = INF -    for s in [s_list[near_right_s - 1], s_list[near_right_s]]: -        for t in [t_list[near_right_t - 1], t_list[near_right_t]]: -            distance_1 = abs(s - x) + abs(t - s) -            distance_2 = abs(t - x) + abs(s - t) -            min_distance = min(min_distance, distance_1, distance_2) -    print(min_distance) +    s_inx = bisect(s, x) +    t_inx = bisect(t, x) +    s_l = s[s_inx - 1] +    s_r = s[s_inx] +    t_l = t[t_inx - 1] +    t_r = t[t_inx] +    ans = 10**18 +    for i in [s_l, s_r]: +        for j in [t_l, t_r]: +            ans = min(ans, abs(i - x) + abs(j - i)) +    for i in [t_l, t_r]: +        for j in [s_l, s_r]: +            ans = min(ans, abs(i - x) + abs(j - i)) +    print(ans)