import bisect

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

inf=10**18

s=[-inf]+[int(eval(input())) for i in range(A)]+[inf]

t=[-inf]+[int(eval(input())) for i in range(B)]+[inf]



for i in range(Q):

  ans=inf

  x=int(eval(input()))

  b=bisect.bisect_left(s,x)

  d=bisect.bisect_left(t,x)

  for S in (s[b-1],s[b]):

    for T in (t[d-1],t[d]):

      ans=min(ans,abs(S-x)+abs(S-T),abs(T-x)+abs(S-T))

  print(ans)
import sys



read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs = sys.stdin.buffer.readlines



# rstrip().decode('utf-8')

# map(int,input().split())

# import numpy as np



inf=10**18



import bisect



def main():

	a,b,q=list(map(int,input().split()))

	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)]

	

	

	for i in x:

		si=bisect.bisect_left(s,i)

		ti=bisect.bisect_left(t,i)

		

		ans=inf

		for S in [s[si-1],s[si]]:

			for T in [t[ti-1],t[ti]]:

				ans=min(ans,abs(S-i)+abs(S-T),abs(T-i)+abs(S-T))

		print(ans)

		

		

		

	



if __name__ == "__main__":

	main()

import bisect

A, B, Q = list(map(int, input().split()))
inf = 10**18
s = [-inf] + [int(eval(input())) for i in range(A)] + [inf]
t = [-inf] + [int(eval(input())) for i in range(B)] + [inf]
for i in range(Q):
    ans = inf
    x = int(eval(input()))
    b = bisect.bisect_left(s, x)
    d = bisect.bisect_left(t, x)
    for S in (s[b - 1], s[b]):
        for T in (t[d - 1], t[d]):
            ans = min(ans, abs(S - x) + abs(S - T), abs(T - x) + abs(S - T))
    print(ans)

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
inf = 10**18
import bisect


def main():
    a, b, q = list(map(int, input().split()))
    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)]
    for i in x:
        si = bisect.bisect_left(s, i)
        ti = bisect.bisect_left(t, i)
        ans = inf
        for S in [s[si - 1], s[si]]:
            for T in [t[ti - 1], t[ti]]:
                ans = min(ans, abs(S - i) + abs(S - T), abs(T - i) + abs(S - T))
        print(ans)


if __name__ == "__main__":
    main()

+import sys + +read = sys.stdin.buffer.read +input = sys.stdin.buffer.readline +inputs = sys.stdin.buffer.readlines +# rstrip().decode('utf-8') +# map(int,input().split()) +# import numpy as np +inf = 10**18 -A, B, Q = list(map(int, input().split())) -inf = 10**18 -s = [-inf] + [int(eval(input())) for i in range(A)] + [inf] -t = [-inf] + [int(eval(input())) for i in range(B)] + [inf] -for i in range(Q): -    ans = inf -    x = int(eval(input())) -    b = bisect.bisect_left(s, x) -    d = bisect.bisect_left(t, x) -    for S in (s[b - 1], s[b]): -        for T in (t[d - 1], t[d]): -            ans = min(ans, abs(S - x) + abs(S - T), abs(T - x) + abs(S - T)) -    print(ans) + +def main(): +    a, b, q = list(map(int, input().split())) +    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)] +    for i in x: +        si = bisect.bisect_left(s, i) +        ti = bisect.bisect_left(t, i) +        ans = inf +        for S in [s[si - 1], s[si]]: +            for T in [t[ti - 1], t[ti]]: +                ans = min(ans, abs(S - i) + abs(S - T), abs(T - i) + abs(S - T)) +        print(ans) + + +if __name__ == "__main__": +    main()