Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
def BinaryIndexSearch_floor(p, SL):
	"""
	search the minimum number among the larger numbers than the ginven nymber "n". 
	return the index of it under the list sorted.
	"""
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] > p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[l] > p:
				return l
			elif SL[r] > p:
				return r
			else:
				return -1

		center = l + ((r-l) // 2)

		if SL[center] <= p:
			l = center + 1
			continue

		else:
			r = center
			continue

def BinaryIndexSearch_ceil(p, SL):
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] < p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[r] < p:
				return r
			elif SL[l] < p:
				return l
			else:
				return -1
		center = l + ((r-l) // 2)

		if SL[center] < p:
			l = center 
			continue

		else:
			r = center - 1
			continue

inf = float("inf")
for i in range(Q):
	xx = x[i]
	I_s_r = BinaryIndexSearch_floor(xx, s)
	I_t_r = BinaryIndexSearch_floor(xx, t)
	I_s_l = BinaryIndexSearch_ceil(xx, s)
	I_t_l = BinaryIndexSearch_ceil(xx, t)

	s_r = inf if I_s_r == -1 else s[I_s_r] - xx
	t_r = inf if I_t_r == -1 else t[I_t_r] - xx
	s_l = inf if I_s_l == -1 else xx - s[I_s_l]
	t_l = inf if I_t_l == -1 else xx - t[I_t_l]

	ans = []

	ans.append(min(s_r,t_l) + s_r + t_l)
	ans.append(min(t_r,s_l) + t_r + s_l)
	ans.append(max(s_r,t_r))
	ans.append(max(s_l,t_l))

	print(min(ans))







Fixed submission:
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
def BinaryIndexSearch_floor(p, SL):
	"""
	search the minimum number among the larger numbers than the ginven nymber "n". 
	return the index of it under the list sorted.
	"""
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] > p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[l] > p:
				return l
			elif SL[r] > p:
				return r
			else:
				return -1

		center = l + ((r-l) // 2)

		if SL[center] <= p:
			l = center + 1
			continue

		else:
			r = center
			continue

def BinaryIndexSearch_ceil(p, SL):
	#SL = sorted(L)
	l = 0
	r = len(SL) - 1

	while True:
		if l == r:
			if SL[l] < p:
				return l
			else:
				return -1
		elif r-l == 1:
			if SL[r] < p:
				return r
			elif SL[l] < p:
				return l
			else:
				return -1
		center = l + ((r-l) // 2)

		if SL[center] < p:
			l = center 
			continue

		else:
			r = center - 1
			continue

inf = float("inf")
for i in range(Q):
	xx = x[i]
	I_s_r = BinaryIndexSearch_floor(xx, s)
	I_t_r = BinaryIndexSearch_floor(xx, t)
	I_s_l = A-1 if I_s_r == -1 else I_s_r - 1
	I_t_l = B-1 if I_t_r == -1 else I_t_r - 1

	s_r = inf if I_s_r == -1 else s[I_s_r] - xx
	t_r = inf if I_t_r == -1 else t[I_t_r] - xx
	s_l = inf if I_s_l == -1 else xx - s[I_s_l]
	t_l = inf if I_t_l == -1 else xx - t[I_t_l]

	ans = []

	ans.append(min(s_r,t_l) + s_r + t_l)
	ans.append(min(t_r,s_l) + t_r + s_l)
	ans.append(max(s_r,t_r))
	ans.append(max(s_l,t_l))

	print(min(ans))