from bisect import bisect_left,bisect_right

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

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

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

for _ in range(q):

  x=int(eval(input()))

  s1,s2=s[bisect_right(s,x)-1],s[bisect_right(s,x)]

  t1,t2=t[bisect_right(t,x)-1],t[bisect_right(t,x)]

  ans=10**11

  for i in [s1,s2]:

    for j in [t1,t2]:

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

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

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

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

x=[int(eval(input()))for _ in range(q)]

from bisect import bisect_left,bisect_right

for xx in x:

  s1=s[bisect_right(s,xx)-1]

  s2=s[bisect_right(s,xx)]

  t1=t[bisect_right(t,xx)-1]

  t2=t[bisect_right(t,xx)]

  ans=[]

  ans.append(abs(s1-t1)+min(abs(xx-s1),abs(xx-t1)))

  ans.append(abs(s1-t2)+min(abs(xx-s1),abs(xx-t2)))

  ans.append(abs(s2-t1)+min(abs(xx-s2),abs(xx-t1)))

  ans.append(abs(s2-t2)+min(abs(xx-s2),abs(xx-t2)))

  print((min(ans)))
from bisect import bisect_left, bisect_right

a, b, q = list(map(int, input().split()))
s = [-(10**21)] + [int(eval(input())) for _ in range(a)] + [10**21]
t = [-(10**21)] + [int(eval(input())) for _ in range(b)] + [10**21]
for _ in range(q):
    x = int(eval(input()))
    s1, s2 = s[bisect_right(s, x) - 1], s[bisect_right(s, x)]
    t1, t2 = t[bisect_right(t, x) - 1], t[bisect_right(t, x)]
    ans = 10**11
    for i in [s1, s2]:
        for j in [t1, t2]:
            ans = min(ans, abs(i - j) + min(abs(x - i), abs(x - j)))
    print(ans)

a, b, q = list(map(int, input().split()))
s = [-(10**30)] + [int(eval(input())) for _ in range(a)] + [10**30]
t = [-(10**30)] + [int(eval(input())) for _ in range(b)] + [10**30]
x = [int(eval(input())) for _ in range(q)]
from bisect import bisect_left, bisect_right

for xx in x:
    s1 = s[bisect_right(s, xx) - 1]
    s2 = s[bisect_right(s, xx)]
    t1 = t[bisect_right(t, xx) - 1]
    t2 = t[bisect_right(t, xx)]
    ans = []
    ans.append(abs(s1 - t1) + min(abs(xx - s1), abs(xx - t1)))
    ans.append(abs(s1 - t2) + min(abs(xx - s1), abs(xx - t2)))
    ans.append(abs(s2 - t1) + min(abs(xx - s2), abs(xx - t1)))
    ans.append(abs(s2 - t2) + min(abs(xx - s2), abs(xx - t2)))
    print((min(ans)))

+a, b, q = list(map(int, input().split())) +s = [-(10**30)] + [int(eval(input())) for _ in range(a)] + [10**30] +t = [-(10**30)] + [int(eval(input())) for _ in range(b)] + [10**30] +x = [int(eval(input())) for _ in range(q)] -a, b, q = list(map(int, input().split())) -s = [-(10**21)] + [int(eval(input())) for _ in range(a)] + [10**21] -t = [-(10**21)] + [int(eval(input())) for _ in range(b)] + [10**21] -for _ in range(q): -    x = int(eval(input())) -    s1, s2 = s[bisect_right(s, x) - 1], s[bisect_right(s, x)] -    t1, t2 = t[bisect_right(t, x) - 1], t[bisect_right(t, x)] -    ans = 10**11 -    for i in [s1, s2]: -        for j in [t1, t2]: -            ans = min(ans, abs(i - j) + min(abs(x - i), abs(x - j))) -    print(ans) +for xx in x: +    s1 = s[bisect_right(s, xx) - 1] +    s2 = s[bisect_right(s, xx)] +    t1 = t[bisect_right(t, xx) - 1] +    t2 = t[bisect_right(t, xx)] +    ans = [] +    ans.append(abs(s1 - t1) + min(abs(xx - s1), abs(xx - t1))) +    ans.append(abs(s1 - t2) + min(abs(xx - s1), abs(xx - t2))) +    ans.append(abs(s2 - t1) + min(abs(xx - s2), abs(xx - t1))) +    ans.append(abs(s2 - t2) + min(abs(xx - s2), abs(xx - t2))) +    print((min(ans)))