import bisect

import itertools



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

INF = 10 ** 15

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

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



for _ in range(Q):

    answer = INF

    x = int(eval(input()))

    si = bisect.bisect_left(S, x)    

    ti = bisect.bisect_left(T, x)

    for s, t in itertools.product(S[si-1:si+1], T[ti-1:ti+1]):

        d = min(abs(s-x), abs(t-x)) + abs(t-s)            

        answer = min(answer, d)

    print(answer)
import bisect

import itertools



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



# 簡略化のため常に左右に存在するようにしておく

INF = 10 ** 15

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

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

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



def solve(x):

  # xの位置

  i = bisect.bisect_left(S, x)

  j = bisect.bisect_left(T, x)

  result = INF

  # どの2つを目指すのか

  for s,t in itertools.product(S[i-1:i+1], T[j-1:j+1]):

    d = min(abs(s-x),abs(t-x)) + abs(t-s)

    result = min(result,d)

  return result



for x in X:

  answer = solve(x)

  print(answer)

import bisect
import itertools

A, B, Q = list(map(int, input().split()))
INF = 10**15
S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
for _ in range(Q):
    answer = INF
    x = int(eval(input()))
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    for s, t in itertools.product(S[si - 1 : si + 1], T[ti - 1 : ti + 1]):
        d = min(abs(s - x), abs(t - x)) + abs(t - s)
        answer = min(answer, d)
    print(answer)

import bisect
import itertools

A, B, Q = list(map(int, input().split()))
# 簡略化のため常に左右に存在するようにしておく
INF = 10**15
S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
X = [int(eval(input())) for _ in range(Q)]


def solve(x):
    # xの位置
    i = bisect.bisect_left(S, x)
    j = bisect.bisect_left(T, x)
    result = INF
    # どの2つを目指すのか
    for s, t in itertools.product(S[i - 1 : i + 1], T[j - 1 : j + 1]):
        d = min(abs(s - x), abs(t - x)) + abs(t - s)
        result = min(result, d)
    return result


for x in X:
    answer = solve(x)
    print(answer)

+# 簡略化のため常に左右に存在するようにしておく -for _ in range(Q): -    answer = INF -    x = int(eval(input())) -    si = bisect.bisect_left(S, x) -    ti = bisect.bisect_left(T, x) -    for s, t in itertools.product(S[si - 1 : si + 1], T[ti - 1 : ti + 1]): +X = [int(eval(input())) for _ in range(Q)] + + +def solve(x): +    # xの位置 +    i = bisect.bisect_left(S, x) +    j = bisect.bisect_left(T, x) +    result = INF +    # どの2つを目指すのか +    for s, t in itertools.product(S[i - 1 : i + 1], T[j - 1 : j + 1]): -        answer = min(answer, d) +        result = min(result, d) +    return result + + +for x in X: +    answer = solve(x)