from bisect import bisect_right
a, b, q = map(int, input().split())
s = [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")]
t = [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")]
x = [int(input()) for i in range(q)]
for i in range(q):
    X = x[i]
    l, r = bisect_right(s, X), bisect_right(t, X)
    ans = float("inf")
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1]))
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r]))
    ans = min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1]))
    ans = min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r]))
    print(ans) from bisect import bisect_right a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for i in range(a) for i in range(a) i range(a) range a for i in range(a) int(input()) int input() input s = [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")] s [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")] [-float("inf")] + [int(input()) for i in range(a)] [-float("inf")] -float("inf") float("inf") float "inf" [int(input()) for i in range(a)] [float("inf")] float("inf") float "inf" int(input()) for i in range(b) for i in range(b) i range(b) range b for i in range(b) int(input()) int input() input t = [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")] t [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")] [-float("inf")] + [int(input()) for i in range(b)] [-float("inf")] -float("inf") float("inf") float "inf" [int(input()) for i in range(b)] [float("inf")] float("inf") float "inf" int(input()) for i in range(q) for i in range(q) i range(q) range q for i in range(q) int(input()) int input() input x = [int(input()) for i in range(q)] x [int(input()) for i in range(q)] for i in range(q):
    X = x[i]
    l, r = bisect_right(s, X), bisect_right(t, X)
    ans = float("inf")
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1]))
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r]))
    ans = min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1]))
    ans = min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r]))
    print(ans) i range(q) range q X = x[i] X x[i] x i l, r = bisect_right(s, X), bisect_right(t, X) l bisect_right(s, X) bisect_right s X r bisect_right(t, X) bisect_right t X ans = float("inf") ans float("inf") float "inf" ans = min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1])) ans min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1])) min ans abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]) abs(s[l - 1] - X) abs s[l - 1] - X s[l - 1] s l - 1 l 1 X abs(t[r - 1] - s[l - 1]) abs t[r - 1] - s[l - 1] t[r - 1] t r - 1 r 1 s[l - 1] s l - 1 l 1 abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1]) abs(t[r - 1] - X) abs t[r - 1] - X t[r - 1] t r - 1 r 1 X abs(s[l - 1] - t[r - 1]) abs s[l - 1] - t[r - 1] s[l - 1] s l - 1 l 1 t[r - 1] t r - 1 r 1 ans = min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r])) ans min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r])) min ans abs(s[l - 1] - X) + abs(t[r] - s[l - 1]) abs(s[l - 1] - X) abs s[l - 1] - X s[l - 1] s l - 1 l 1 X abs(t[r] - s[l - 1]) abs t[r] - s[l - 1] t[r] t r s[l - 1] s l - 1 l 1 abs(t[r] - X) + abs(s[l - 1] - t[r]) abs(t[r] - X) abs t[r] - X t[r] t r X abs(s[l - 1] - t[r]) abs s[l - 1] - t[r] s[l - 1] s l - 1 l 1 t[r] t r ans = min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1])) ans min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1])) min ans abs(s[l] - X) + abs(t[r - 1] - s[l]) abs(s[l] - X) abs s[l] - X s[l] s l X abs(t[r - 1] - s[l]) abs t[r - 1] - s[l] t[r - 1] t r - 1 r 1 s[l] s l abs(t[r - 1] - X) + abs(s[l] - t[r - 1]) abs(t[r - 1] - X) abs t[r - 1] - X t[r - 1] t r - 1 r 1 X abs(s[l] - t[r - 1]) abs s[l] - t[r - 1] s[l] s l t[r - 1] t r - 1 r 1 ans = min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r])) ans min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r])) min ans abs(s[l] - X) + abs(t[r] - s[l]) abs(s[l] - X) abs s[l] - X s[l] s l X abs(t[r] - s[l]) abs t[r] - s[l] t[r] t r s[l] s l abs(t[r] - X) + abs(s[l] - t[r]) abs(t[r] - X) abs t[r] - X t[r] t r X abs(s[l] - t[r]) abs s[l] - t[r] s[l] s l t[r] t r print(ans) print ans l, r = bisect_right(s, X), bisect_right(t, X) bisect_right(s, X) l q = map(int, input().split()) map(int, input().split()) q x = [int(input()) for i in range(q)] [int(input()) for i in range(q)] x a, b, q = map(int, input().split()) map(int, input().split()) a X = x[i] x[i] X ans = min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r])) min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r])) ans r = bisect_right(s, X), bisect_right(t, X) bisect_right(t, X) r ans = float("inf") float("inf") ans t = [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")] [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")] t ans = min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1])) min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1])) ans s = [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")] [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")] s ans = min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r])) min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r])) ans ans = min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1])) min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1])) ans b, q = map(int, input().split()) map(int, input().split()) b
from bisect import bisect_right
a, b, q = map(int, input().split())
s = [-float("inf")] + [int(input()) for i in range(a)] + [float("inf")]
t = [-float("inf")] + [int(input()) for i in range(b)] + [float("inf")]
x = [int(input()) for i in range(q)]
for i in range(q):
    X = x[i]
    l, r = bisect_right(s, X), bisect_right(t, X)
    ans = float("inf")
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r - 1] - s[l - 1]), abs(t[r - 1] - X) + abs(s[l - 1] - t[r - 1]))
    ans = min(ans, abs(s[l - 1] - X) + abs(t[r] - s[l - 1]), abs(t[r] - X) + abs(s[l - 1] - t[r]))
    ans = min(ans, abs(s[l] - X) + abs(t[r - 1] - s[l]), abs(t[r - 1] - X) + abs(s[l] - t[r - 1]))
    ans = min(ans, abs(s[l] - X) + abs(t[r] - s[l]), abs(t[r] - X) + abs(s[l] - t[r]))
    print(ans)