from bisect import bisect_left,bisect_right

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

INF=float("inf")

s=[-INF]+[int(eval(input()))for i in range(a)]+[INF]

t=[-INF]+[int(eval(input()))for i in range(b)]+[INF]

for _ in range(q):

  x=int(eval(input()))

  b,c=bisect_right(s,x),bisect_right(t,x)

  a=INF

  for i in [s[b-1],s[b]]:

    for j in [t[c-1],t[c]]:

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

  print(a)
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)
from bisect import bisect_left, bisect_right

a, b, q = list(map(int, input().split()))
INF = float("inf")
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
    x = int(eval(input()))
    b, c = bisect_right(s, x), bisect_right(t, x)
    a = INF
    for i in [s[b - 1], s[b]]:
        for j in [t[c - 1], t[c]]:
            a = min(a, abs(x - i) + abs(i - j), abs(x - j) + abs(j - i))
    print(a)

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)

-INF = float("inf") -s = [-INF] + [int(eval(input())) for i in range(a)] + [INF] -t = [-INF] + [int(eval(input())) for i in range(b)] + [INF] +s = [-(10**21)] + [int(eval(input())) for _ in range(a)] + [10**21] +t = [-(10**21)] + [int(eval(input())) for _ in range(b)] + [10**21] -    b, c = bisect_right(s, x), bisect_right(t, x) -    a = INF -    for i in [s[b - 1], s[b]]: -        for j in [t[c - 1], t[c]]: -            a = min(a, abs(x - i) + abs(i - j), abs(x - j) + abs(j - i)) -    print(a) +    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)