import numpy as np

A, B, Q, *L = list(map(int, open(0).read().split()))

s = L[:A]

t = L[A:A+B]

x = L[A+B:]



s = [-float('inf')]+s+[float('inf')]

t = [-float('inf')]+t+[float('inf')]

sls = np.searchsorted(s,x)

tls = np.searchsorted(t,x)

for ar, br, c in zip(sls,tls,x):

  bl = br-1

  al = ar-1

  n = s[ar]-t[bl]+min(s[ar]-c,c-t[bl])

  m = t[br]-s[al]+min(t[br]-c,c-s[al])

  p = c-min(t[bl],s[al])

  q = max(s[ar],t[br])-c

  print((min(n,m,p,q)))
from bisect import bisect_left

A, B, Q, *L = list(map(int, open(0).read().split()))

s = L[:A]

t = L[A:A+B]

x = L[A+B:]



s = [-float('inf')]+s+[float('inf')]

t = [-float('inf')]+t+[float('inf')]

for c in x:

  br = bisect_left(t,c)

  ar = bisect_left(s,c)

  bl = br-1

  al = ar-1

  print((min(s[ar]-t[bl]+min(s[ar]-c,c-t[bl]),t[br]-s[al]+min(t[br]-c,c-s[al]),

            c-min(t[bl],s[al]),max(s[ar],t[br])-c)))
import numpy as np

A, B, Q, *L = list(map(int, open(0).read().split()))
s = L[:A]
t = L[A : A + B]
x = L[A + B :]
s = [-float("inf")] + s + [float("inf")]
t = [-float("inf")] + t + [float("inf")]
sls = np.searchsorted(s, x)
tls = np.searchsorted(t, x)
for ar, br, c in zip(sls, tls, x):
    bl = br - 1
    al = ar - 1
    n = s[ar] - t[bl] + min(s[ar] - c, c - t[bl])
    m = t[br] - s[al] + min(t[br] - c, c - s[al])
    p = c - min(t[bl], s[al])
    q = max(s[ar], t[br]) - c
    print((min(n, m, p, q)))

from bisect import bisect_left

A, B, Q, *L = list(map(int, open(0).read().split()))
s = L[:A]
t = L[A : A + B]
x = L[A + B :]
s = [-float("inf")] + s + [float("inf")]
t = [-float("inf")] + t + [float("inf")]
for c in x:
    br = bisect_left(t, c)
    ar = bisect_left(s, c)
    bl = br - 1
    al = ar - 1
    print(
        (
            min(
                s[ar] - t[bl] + min(s[ar] - c, c - t[bl]),
                t[br] - s[al] + min(t[br] - c, c - s[al]),
                c - min(t[bl], s[al]),
                max(s[ar], t[br]) - c,
            )
        )
    )

-import numpy as np +from bisect import bisect_left -sls = np.searchsorted(s, x) -tls = np.searchsorted(t, x) -for ar, br, c in zip(sls, tls, x): +for c in x: +    br = bisect_left(t, c) +    ar = bisect_left(s, c) -    n = s[ar] - t[bl] + min(s[ar] - c, c - t[bl]) -    m = t[br] - s[al] + min(t[br] - c, c - s[al]) -    p = c - min(t[bl], s[al]) -    q = max(s[ar], t[br]) - c -    print((min(n, m, p, q))) +    print( +        ( +            min( +                s[ar] - t[bl] + min(s[ar] - c, c - t[bl]), +                t[br] - s[al] + min(t[br] - c, c - s[al]), +                c - min(t[bl], s[al]), +                max(s[ar], t[br]) - c, +            ) +        ) +    )