from bisect import bisect_left, bisect_right
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_right(temple, x)
    for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

    for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    print(ans) from bisect import bisect_left, bisect_right 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_right(temple, x)
    for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

    for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    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_right(temple, x) index_t bisect_right(temple, x) bisect_right temple x for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

     i range(index_s-1, index_s+1) range index_s-1 index_s 1 index_s+1 index_s 1 s = shrine[i] s shrine[i] shrine i i_t = index_t i_t index_t t0, t1 = temple[i_t-1], temple[i_t] t0 temple[i_t-1] temple i_t-1 i_t 1 t1 temple[i_t] temple i_t ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        ) ans min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        ) min ans abs(x - s) + abs(s - t0) abs(x - s) abs x - s x s abs(s - t0) abs s - t0 s t0 abs(x - s) + abs(s - t1) abs(x - s) abs x - s x s abs(s - t1) abs s - t1 s t1 for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

     i range(index_t-1, index_t+1) range index_t-1 index_t 1 index_t+1 index_t 1 t = temple[i] t temple[i] temple i i_s = index_s i_s index_s s0 = shrine[i_s - 1] s0 shrine[i_s - 1] shrine i_s - 1 i_s 1 s1 = shrine[i_s] s1 shrine[i_s] shrine i_s ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        ) ans min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        ) min ans abs(x - t) + abs(t - s0) abs(x - t) abs x - t x t abs(t - s0) abs t - s0 t s0 abs(x - t) + abs(t - s1) abs(x - t) abs x - t x t abs(t - s1) abs t - s1 t s1 print(ans) print ans s = shrine[i] shrine[i] s inf = 10**18 10**18 inf index_t = bisect_right(temple, x) bisect_right(temple, x) index_t b, q = map(int, input().split()) map(int, input().split()) b t1 = temple[i_t-1], temple[i_t] temple[i_t] t1 s0 = shrine[i_s - 1] shrine[i_s - 1] s0 t = temple[i] temple[i] t s1 = shrine[i_s] shrine[i_s] s1 ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        ) min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        ) ans i_s = index_s index_s i_s ans = inf inf ans ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        ) min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        ) ans q = map(int, input().split()) map(int, input().split()) q x = int(input()) int(input()) x index_s = bisect_left(shrine, x) bisect_left(shrine, x) index_s i_t = index_t index_t i_t temple = [-inf] + [int(input()) for _ in range(b)] + [inf] [-inf] + [int(input()) for _ in range(b)] + [inf] temple shrine = [-inf] + [int(input()) for _ in range(a)] + [inf] [-inf] + [int(input()) for _ in range(a)] + [inf] shrine a, b, q = map(int, input().split()) map(int, input().split()) a t0, t1 = temple[i_t-1], temple[i_t] temple[i_t-1] t0
from bisect import bisect_left, bisect_right
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_right(temple, x)
    for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

    for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    print(ans)
