import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
inf = pow(10, 12)
s.insert(0, -inf)
s.append(inf)
t.insert(0, -inf)
t.append(inf)
for i in x:
    u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i)
    s1, s2 = s[u - 1], s[u]
    t1, t2 = t[v - 1], t[v]
    d1 = max(i - s1, i - t1)
    d2 = max(s2 - i, t2 - i)
    d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i)
    d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i)
    print(min(d1, d2, d3, d4)) import bisect bisect a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input s = [int(input()) for _ in range(a)] s [int(input()) for _ in range(a)] int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input t = [int(input()) for _ in range(b)] t [int(input()) for _ in range(b)] int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input x = [int(input()) for _ in range(q)] x [int(input()) for _ in range(q)] inf = pow(10, 12) inf pow(10, 12) pow 10 12 s.insert(0, -inf) s.insert s insert 0 -inf inf s.append(inf) s.append s append inf t.insert(0, -inf) t.insert t insert 0 -inf inf t.append(inf) t.append t append inf for i in x:
    u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i)
    s1, s2 = s[u - 1], s[u]
    t1, t2 = t[v - 1], t[v]
    d1 = max(i - s1, i - t1)
    d2 = max(s2 - i, t2 - i)
    d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i)
    d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i)
    print(min(d1, d2, d3, d4)) i x u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i) u bisect.bisect_left(s, i) bisect.bisect_left bisect bisect_left s i v bisect.bisect_left(t, i) bisect.bisect_left bisect bisect_left t i s1, s2 = s[u - 1], s[u] s1 s[u - 1] s u - 1 u 1 s2 s[u] s u t1, t2 = t[v - 1], t[v] t1 t[v - 1] t v - 1 v 1 t2 t[v] t v d1 = max(i - s1, i - t1) d1 max(i - s1, i - t1) max i - s1 i s1 i - t1 i t1 d2 = max(s2 - i, t2 - i) d2 max(s2 - i, t2 - i) max s2 - i s2 i t2 - i t2 i d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i) d3 max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i) max(i - s1, t2 - i) max i - s1 i s1 t2 - i t2 i 2 * min(i - s1, t2 - i) 2 min(i - s1, t2 - i) min i - s1 i s1 t2 - i t2 i d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i) d4 max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i) max(i - t1, s2 - i) max i - t1 i t1 s2 - i s2 i 2 * min(i - t1, s2 - i) 2 min(i - t1, s2 - i) min i - t1 i t1 s2 - i s2 i print(min(d1, d2, d3, d4)) print min(d1, d2, d3, d4) min d1 d2 d3 d4 v = bisect.bisect_left(s, i), bisect.bisect_left(t, i) bisect.bisect_left(t, i) v t = [int(input()) for _ in range(b)] [int(input()) for _ in range(b)] t b, q = map(int, input().split()) map(int, input().split()) b d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i) max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i) d3 x = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] x d1 = max(i - s1, i - t1) max(i - s1, i - t1) d1 q = map(int, input().split()) map(int, input().split()) q d2 = max(s2 - i, t2 - i) max(s2 - i, t2 - i) d2 d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i) max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i) d4 s = [int(input()) for _ in range(a)] [int(input()) for _ in range(a)] s s1, s2 = s[u - 1], s[u] s[u - 1] s1 u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i) bisect.bisect_left(s, i) u s2 = s[u - 1], s[u] s[u] s2 a, b, q = map(int, input().split()) map(int, input().split()) a t1, t2 = t[v - 1], t[v] t[v - 1] t1 t2 = t[v - 1], t[v] t[v] t2 inf = pow(10, 12) pow(10, 12) inf
import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
inf = pow(10, 12)
s.insert(0, -inf)
s.append(inf)
t.insert(0, -inf)
t.append(inf)
for i in x:
    u, v = bisect.bisect_left(s, i), bisect.bisect_left(t, i)
    s1, s2 = s[u - 1], s[u]
    t1, t2 = t[v - 1], t[v]
    d1 = max(i - s1, i - t1)
    d2 = max(s2 - i, t2 - i)
    d3 = max(i - s1, t2 - i) + 2 * min(i - s1, t2 - i)
    d4 = max(i - t1, s2 - i) + 2 * min(i - t1, s2 - i)
    print(min(d1, d2, d3, d4))