from bisect import bisect_left

INF = 10**18

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

als = [int(eval(input())) for i in range(A)]

bls = [int(eval(input())) for i in range(B)]

als = [-INF]+als+[INF]

bls = [-INF]+bls+[INF]



for i in range(Q):

  x = int(eval(input()))

  ai = bisect_left(als,x)

  bi = bisect_left(bls,x)

  res = INF

  for S in [als[ai], als[ai-1]]:

    for T in [bls[bi], bls[bi-1]]:

      d1, d2 = abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)

      res = min(res,d1,d2)

  print(res)
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

INF = 10**18
A, B, Q = list(map(int, input().split()))
als = [int(eval(input())) for i in range(A)]
bls = [int(eval(input())) for i in range(B)]
als = [-INF] + als + [INF]
bls = [-INF] + bls + [INF]
for i in range(Q):
    x = int(eval(input()))
    ai = bisect_left(als, x)
    bi = bisect_left(bls, x)
    res = INF
    for S in [als[ai], als[ai - 1]]:
        for T in [bls[bi], bls[bi - 1]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

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 +import numpy as np -INF = 10**18 -A, B, Q = list(map(int, input().split())) -als = [int(eval(input())) for i in range(A)] -bls = [int(eval(input())) for i in range(B)] -als = [-INF] + als + [INF] -bls = [-INF] + bls + [INF] -for i in range(Q): -    x = int(eval(input())) -    ai = bisect_left(als, x) -    bi = bisect_left(bls, x) -    res = INF -    for S in [als[ai], als[ai - 1]]: -        for T in [bls[bi], bls[bi - 1]]: -            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) -            res = min(res, d1, d2) -    print(res) +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)))