import bisect
import sys
readline = sys.stdin.buffer.readline


def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res)

if __name__ == '__main__':
    main() import bisect bisect import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res) main A, B, Q = map(int, readline().split()) A map(int, readline().split()) map int readline().split() ().split () readline split B Q inf = 10 ** 18 inf 10 ** 18 10 18 int(readline()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(readline()) int readline() readline s = [-inf] + [int(readline()) for _ in range(A)] + [inf] s [-inf] + [int(readline()) for _ in range(A)] + [inf] [-inf] + [int(readline()) for _ in range(A)] [-inf] -inf inf [int(readline()) for _ in range(A)] [inf] inf int(readline()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(readline()) int readline() readline t = [-inf] + [int(readline()) for _ in range(B)] + [inf] t [-inf] + [int(readline()) for _ in range(B)] + [inf] [-inf] + [int(readline()) for _ in range(B)] [-inf] -inf inf [int(readline()) for _ in range(B)] [inf] inf for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res) q range(Q) range Q x = int(readline()) x int(readline()) int readline() readline b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x) b bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x d bisect.bisect_left(t, x) bisect.bisect_left bisect bisect_left t x res = inf res inf for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
         S [s[b - 1], s[b]] s[b - 1] s b - 1 b 1 s[b] s b for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
         T [t[d - 1], t[d]] t[d - 1] t d - 1 d 1 t[d] t d d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) d1 abs(S - x) + abs(T - S) abs(S - x) abs S - x S x abs(T - S) abs T - S T S d2 abs(T - x) + abs(S - T) abs(T - x) abs T - x T x abs(S - T) abs S - T S T res = min(res, d1, d2) res min(res, d1, d2) min res d1 d2 print(res) print res if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res) def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res) main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import bisect
import sys
readline = sys.stdin.buffer.readline


def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res)

if __name__ == '__main__':
    main()
