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

S,T,X=[[int(eval(input())) for i in range(A[j])] for j in range(3)]

def binary(a,l,):

	low=0

	high=len(l)-1

	while high-low>1:

		mid=(low+high)//2

		if l[mid]<a:

			low=mid

		else:

			high=mid

	return [l[high],l[low]]

			

for x in X:

	s=set(binary(x,S))

	t=set(binary(x,T))

	Min=20000000000

	for i in s:

		for j in t:

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

	print(Min)

	
import sys

input=sys.stdin.readline

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

S,T,X=[[int(eval(input())) for i in range(A[j])] for j in range(3)]

def binary(a,l,):

	low=0

	high=len(l)-1

	while high-low>1:

		mid=(low+high)//2

		if l[mid]<a:

			low=mid

		else:

			high=mid

	return [l[high],l[low]]

			

for x in X:

	s=set(binary(x,S))

	t=set(binary(x,T))

	Min=20000000000

	for i in s:

		for j in t:

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

	print(Min)

	
A = list(map(int, input().split()))
S, T, X = [[int(eval(input())) for i in range(A[j])] for j in range(3)]


def binary(
    a,
    l,
):
    low = 0
    high = len(l) - 1
    while high - low > 1:
        mid = (low + high) // 2
        if l[mid] < a:
            low = mid
        else:
            high = mid
    return [l[high], l[low]]


for x in X:
    s = set(binary(x, S))
    t = set(binary(x, T))
    Min = 20000000000
    for i in s:
        for j in t:
            Min = min(Min, min(abs(x - i), abs(x - j)) + abs(i - j))
    print(Min)

import sys

input = sys.stdin.readline
A = list(map(int, input().split()))
S, T, X = [[int(eval(input())) for i in range(A[j])] for j in range(3)]


def binary(
    a,
    l,
):
    low = 0
    high = len(l) - 1
    while high - low > 1:
        mid = (low + high) // 2
        if l[mid] < a:
            low = mid
        else:
            high = mid
    return [l[high], l[low]]


for x in X:
    s = set(binary(x, S))
    t = set(binary(x, T))
    Min = 20000000000
    for i in s:
        for j in t:
            Min = min(Min, min(abs(x - i), abs(x - j)) + abs(i - j))
    print(Min)

+import sys + +input = sys.stdin.readline