from bisect import bisect_left
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_left(temple, x)

    for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

    print(ans) 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 inf = 10**18 inf 10**18 10 18 int(input()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input shrine = [-inf] + [int(input()) for _ in range(a)] + [inf] shrine [-inf] + [int(input()) for _ in range(a)] + [inf] [-inf] + [int(input()) for _ in range(a)] [-inf] -inf inf [int(input()) for _ in range(a)] [inf] inf int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input temple = [-inf] + [int(input()) for _ in range(b)] + [inf] temple [-inf] + [int(input()) for _ in range(b)] + [inf] [-inf] + [int(input()) for _ in range(b)] [-inf] -inf inf [int(input()) for _ in range(b)] [inf] inf for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_left(temple, x)

    for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

    print(ans) _ range(q) range q ans = inf ans inf x = int(input()) x int(input()) int input() input index_s = bisect_left(shrine, x) index_s bisect_left(shrine, x) bisect_left shrine x index_t = bisect_left(temple, x) index_t bisect_left(temple, x) bisect_left temple x for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

     s [shrine[index_s-1], shrine[index_s]] shrine[index_s-1] shrine index_s-1 index_s 1 shrine[index_s] shrine index_s for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

     t [temple[index_t-1], temple[index_t]] temple[index_t-1] temple index_t-1 index_t 1 temple[index_t] temple index_t ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            ) ans min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            ) min ans abs(x-s) + abs(s-t) abs(x-s) abs x-s x s abs(s-t) abs s-t s t abs(x-t) + abs(s-t) abs(x-t) abs x-t x t abs(s-t) abs s-t s t print(ans) print ans ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            ) min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            ) ans a, b, q = map(int, input().split()) map(int, input().split()) a shrine = [-inf] + [int(input()) for _ in range(a)] + [inf] [-inf] + [int(input()) for _ in range(a)] + [inf] shrine temple = [-inf] + [int(input()) for _ in range(b)] + [inf] [-inf] + [int(input()) for _ in range(b)] + [inf] temple ans = inf inf ans index_t = bisect_left(temple, x) bisect_left(temple, x) index_t x = int(input()) int(input()) x q = map(int, input().split()) map(int, input().split()) q inf = 10**18 10**18 inf index_s = bisect_left(shrine, x) bisect_left(shrine, x) index_s b, q = map(int, input().split()) map(int, input().split()) b
from bisect import bisect_left
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_left(temple, x)

    for s in [shrine[index_s-1], shrine[index_s]]:
        for t in [temple[index_t-1], temple[index_t]]:
            ans = min(
                ans,
                abs(x-s) + abs(s-t),
                abs(x-t) + abs(s-t)
            )

    print(ans)
