from bisect import bisect_left
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]+[10**15]
t = [int(input()) for _ in range(B)]+[10**15]

for _ in range(Q):
    x = int(input())

    # x -> s -> t
    dist1, dist2 = 0, 0
    p1 = bisect_left(s, x)
    x1, x2 = s[p1-1], s[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(t, x1)
    x3, x4 = t[p3-1], t[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(t, x2)
    x3, x4 = t[p3-1], t[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_st = min(dist1, dist2)

    # x -> t -> s

    dist1, dist2 = 0, 0
    p1 = bisect_left(t, x)
    x1, x2 = t[p1-1], t[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(s, x1)
    x3, x4 = s[p3-1], s[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(s, x2)
    x3, x4 = s[p3-1], s[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_ts = min(dist1, dist2)

    print(min(dist_st, dist_ts)) from bisect import bisect_left 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)]+[10**15] s [int(input()) for _ in range(A)]+[10**15] [int(input()) for _ in range(A)] [10**15] 10**15 10 15 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)]+[10**15] t [int(input()) for _ in range(B)]+[10**15] [int(input()) for _ in range(B)] [10**15] 10**15 10 15 for _ in range(Q):
    x = int(input())

    # x -> s -> t
    dist1, dist2 = 0, 0
    p1 = bisect_left(s, x)
    x1, x2 = s[p1-1], s[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(t, x1)
    x3, x4 = t[p3-1], t[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(t, x2)
    x3, x4 = t[p3-1], t[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_st = min(dist1, dist2)

    # x -> t -> s

    dist1, dist2 = 0, 0
    p1 = bisect_left(t, x)
    x1, x2 = t[p1-1], t[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(s, x1)
    x3, x4 = s[p3-1], s[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(s, x2)
    x3, x4 = s[p3-1], s[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_ts = min(dist1, dist2)

    print(min(dist_st, dist_ts)) _ range(Q) range Q x = int(input()) x int(input()) int input() input dist1, dist2 = 0, 0 dist1 0 dist2 0 p1 = bisect_left(s, x) p1 bisect_left(s, x) bisect_left s x x1, x2 = s[p1-1], s[p1] x1 s[p1-1] s p1-1 p1 1 x2 s[p1] s p1 dist1 += abs(x-x1) dist1 abs(x-x1) abs x-x1 x x1 dist2 += abs(x-x2) dist2 abs(x-x2) abs x-x2 x x2 p3 = bisect_left(t, x1) p3 bisect_left(t, x1) bisect_left t x1 x3, x4 = t[p3-1], t[p3] x3 t[p3-1] t p3-1 p3 1 x4 t[p3] t p3 dist1 += min(abs(x1-x3),abs(x1-x4)) dist1 min(abs(x1-x3),abs(x1-x4)) min abs(x1-x3) abs x1-x3 x1 x3 abs(x1-x4) abs x1-x4 x1 x4 p3 = bisect_left(t, x2) p3 bisect_left(t, x2) bisect_left t x2 x3, x4 = t[p3-1], t[p3] x3 t[p3-1] t p3-1 p3 1 x4 t[p3] t p3 dist2 += min(abs(x2-x3),abs(x2-x4)) dist2 min(abs(x2-x3),abs(x2-x4)) min abs(x2-x3) abs x2-x3 x2 x3 abs(x2-x4) abs x2-x4 x2 x4 dist_st = min(dist1, dist2) dist_st min(dist1, dist2) min dist1 dist2 dist1, dist2 = 0, 0 dist1 0 dist2 0 p1 = bisect_left(t, x) p1 bisect_left(t, x) bisect_left t x x1, x2 = t[p1-1], t[p1] x1 t[p1-1] t p1-1 p1 1 x2 t[p1] t p1 dist1 += abs(x-x1) dist1 abs(x-x1) abs x-x1 x x1 dist2 += abs(x-x2) dist2 abs(x-x2) abs x-x2 x x2 p3 = bisect_left(s, x1) p3 bisect_left(s, x1) bisect_left s x1 x3, x4 = s[p3-1], s[p3] x3 s[p3-1] s p3-1 p3 1 x4 s[p3] s p3 dist1 += min(abs(x1-x3),abs(x1-x4)) dist1 min(abs(x1-x3),abs(x1-x4)) min abs(x1-x3) abs x1-x3 x1 x3 abs(x1-x4) abs x1-x4 x1 x4 p3 = bisect_left(s, x2) p3 bisect_left(s, x2) bisect_left s x2 x3, x4 = s[p3-1], s[p3] x3 s[p3-1] s p3-1 p3 1 x4 s[p3] s p3 dist2 += min(abs(x2-x3),abs(x2-x4)) dist2 min(abs(x2-x3),abs(x2-x4)) min abs(x2-x3) abs x2-x3 x2 x3 abs(x2-x4) abs x2-x4 x2 x4 dist_ts = min(dist1, dist2) dist_ts min(dist1, dist2) min dist1 dist2 print(min(dist_st, dist_ts)) print min(dist_st, dist_ts) min dist_st dist_ts x2 = s[p1-1], s[p1] s[p1] x2 x1, x2 = t[p1-1], t[p1] t[p1-1] x1 x4 = s[p3-1], s[p3] s[p3] x4 t = [int(input()) for _ in range(B)]+[10**15] [int(input()) for _ in range(B)]+[10**15] t dist_st = min(dist1, dist2) min(dist1, dist2) dist_st dist1 += min(abs(x1-x3),abs(x1-x4)) min(abs(x1-x3),abs(x1-x4)) dist1 p3 = bisect_left(t, x2) bisect_left(t, x2) p3 dist1, dist2 = 0, 0 0 dist1 A, B, Q = map(int, input().split()) map(int, input().split()) A dist2 += min(abs(x2-x3),abs(x2-x4)) min(abs(x2-x3),abs(x2-x4)) dist2 Q = map(int, input().split()) map(int, input().split()) Q x3, x4 = t[p3-1], t[p3] t[p3-1] x3 x1, x2 = s[p1-1], s[p1] s[p1-1] x1 dist2 += abs(x-x2) abs(x-x2) dist2 dist2 = 0, 0 0 dist2 dist_ts = min(dist1, dist2) min(dist1, dist2) dist_ts x4 = t[p3-1], t[p3] t[p3] x4 x3, x4 = s[p3-1], s[p3] s[p3-1] x3 dist2 = 0, 0 0 dist2 p1 = bisect_left(t, x) bisect_left(t, x) p1 p3 = bisect_left(s, x2) bisect_left(s, x2) p3 x4 = t[p3-1], t[p3] t[p3] x4 p3 = bisect_left(s, x1) bisect_left(s, x1) p3 p1 = bisect_left(s, x) bisect_left(s, x) p1 x = int(input()) int(input()) x dist1 += abs(x-x1) abs(x-x1) dist1 B, Q = map(int, input().split()) map(int, input().split()) B dist1, dist2 = 0, 0 0 dist1 s = [int(input()) for _ in range(A)]+[10**15] [int(input()) for _ in range(A)]+[10**15] s dist1 += min(abs(x1-x3),abs(x1-x4)) min(abs(x1-x3),abs(x1-x4)) dist1 dist1 += abs(x-x1) abs(x-x1) dist1 dist2 += abs(x-x2) abs(x-x2) dist2 x3, x4 = s[p3-1], s[p3] s[p3-1] x3 p3 = bisect_left(t, x1) bisect_left(t, x1) p3 dist2 += min(abs(x2-x3),abs(x2-x4)) min(abs(x2-x3),abs(x2-x4)) dist2 x2 = t[p1-1], t[p1] t[p1] x2 x3, x4 = t[p3-1], t[p3] t[p3-1] x3 x4 = s[p3-1], s[p3] s[p3] x4
from bisect import bisect_left
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]+[10**15]
t = [int(input()) for _ in range(B)]+[10**15]

for _ in range(Q):
    x = int(input())

    # x -> s -> t
    dist1, dist2 = 0, 0
    p1 = bisect_left(s, x)
    x1, x2 = s[p1-1], s[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(t, x1)
    x3, x4 = t[p3-1], t[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(t, x2)
    x3, x4 = t[p3-1], t[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_st = min(dist1, dist2)

    # x -> t -> s

    dist1, dist2 = 0, 0
    p1 = bisect_left(t, x)
    x1, x2 = t[p1-1], t[p1]
    dist1 += abs(x-x1)
    dist2 += abs(x-x2)

    p3 = bisect_left(s, x1)
    x3, x4 = s[p3-1], s[p3]
    dist1 += min(abs(x1-x3),abs(x1-x4))

    p3 = bisect_left(s, x2)
    x3, x4 = s[p3-1], s[p3]
    dist2 += min(abs(x2-x3),abs(x2-x4))

    dist_ts = min(dist1, dist2)

    print(min(dist_st, dist_ts))