import sys

import bisect

input = sys.stdin.readline



A, B, Q = map(int, input().split())

tera = [int(input()) for _ in range(A)]

sha = [int(input()) for _ in range(B)]

query = [int(input()) for _ in range(Q)]

res = []



for x in query:

    tl = bisect.bisect_left(tera, x)

    tr = bisect.bisect_right(tera, x)

    sl = bisect.bisect_left(sha, x)

    sr = bisect.bisect_right(sha, x)



    if tl == 0:

        temple = [tera[0]]

    elif tr == A:

        temple = [tera[A - 1]]

    else:

        temple = [tera[tl-1], tera[tl]]



    if sl == 0:

        shrine = [sha[0]]

    elif sr == B:

        shrine = [sha[B - 1]]

    else:

        shrine = [sha[sl-1], sha[sl]]



    ans = 10**18

    for t in temple:

        for s in shrine:

            tx = t - x

            sx = s - x

            if tx * sx >= 0:

                a = max(abs(tx), abs(sx))

            else:

                a = min(2 * abs(tx) + abs(sx), 2 * abs(sx) + abs(tx))

            ans = min(ans, a)

    res.append(ans)



print(*res, sep="\n")

import sys

import bisect

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 7)

bl = bisect.bisect_left



A, B, Q = list(map(int, input().split()))

inf = 10**18

S = [-inf]+[int(eval(input())) for _ in range(A)]+[inf]

T = [-inf]+[int(eval(input())) for _ in range(B)]+[inf]





def path(x):

    sl = S[bl(S, x) - 1]

    sr = S[bl(S, x)]

    tl = T[bl(T, x) - 1]

    tr = T[bl(T, x)]



    res = 10 ** 18

    res = min(res, abs(x - sl) + abs(sl - tl))

    res = min(res, abs(x - sl) + abs(sl - tr))

    res = min(res, abs(x - sr) + abs(sr - tr))

    res = min(res, abs(x - sr) + abs(sr - tl))

    res = min(res, abs(x - tr) + abs(tr - sl))

    res = min(res, abs(x - tr) + abs(tr - sr))

    res = min(res, abs(x - tl) + abs(tl - sl))

    res = min(res, abs(x - tl) + abs(tl - sr))

    return res





X = [int(eval(input())) for _ in range(Q)]

for x in X:

    print((path(x)))
import sys
import bisect

input = sys.stdin.readline
A, B, Q = map(int, input().split())
tera = [int(input()) for _ in range(A)]
sha = [int(input()) for _ in range(B)]
query = [int(input()) for _ in range(Q)]
res = []
for x in query:
    tl = bisect.bisect_left(tera, x)
    tr = bisect.bisect_right(tera, x)
    sl = bisect.bisect_left(sha, x)
    sr = bisect.bisect_right(sha, x)
    if tl == 0:
        temple = [tera[0]]
    elif tr == A:
        temple = [tera[A - 1]]
    else:
        temple = [tera[tl - 1], tera[tl]]
    if sl == 0:
        shrine = [sha[0]]
    elif sr == B:
        shrine = [sha[B - 1]]
    else:
        shrine = [sha[sl - 1], sha[sl]]
    ans = 10**18
    for t in temple:
        for s in shrine:
            tx = t - x
            sx = s - x
            if tx * sx >= 0:
                a = max(abs(tx), abs(sx))
            else:
                a = min(2 * abs(tx) + abs(sx), 2 * abs(sx) + abs(tx))
            ans = min(ans, a)
    res.append(ans)
print(*res, sep="\n")

import sys
import bisect

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
bl = bisect.bisect_left
A, B, Q = list(map(int, input().split()))
inf = 10**18
S = [-inf] + [int(eval(input())) for _ in range(A)] + [inf]
T = [-inf] + [int(eval(input())) for _ in range(B)] + [inf]


def path(x):
    sl = S[bl(S, x) - 1]
    sr = S[bl(S, x)]
    tl = T[bl(T, x) - 1]
    tr = T[bl(T, x)]
    res = 10**18
    res = min(res, abs(x - sl) + abs(sl - tl))
    res = min(res, abs(x - sl) + abs(sl - tr))
    res = min(res, abs(x - sr) + abs(sr - tr))
    res = min(res, abs(x - sr) + abs(sr - tl))
    res = min(res, abs(x - tr) + abs(tr - sl))
    res = min(res, abs(x - tr) + abs(tr - sr))
    res = min(res, abs(x - tl) + abs(tl - sl))
    res = min(res, abs(x - tl) + abs(tl - sr))
    return res


X = [int(eval(input())) for _ in range(Q)]
for x in X:
    print((path(x)))

-input = sys.stdin.readline -A, B, Q = map(int, input().split()) -tera = [int(input()) for _ in range(A)] -sha = [int(input()) for _ in range(B)] -query = [int(input()) for _ in range(Q)] -res = [] -for x in query: -    tl = bisect.bisect_left(tera, x) -    tr = bisect.bisect_right(tera, x) -    sl = bisect.bisect_left(sha, x) -    sr = bisect.bisect_right(sha, x) -    if tl == 0: -        temple = [tera[0]] -    elif tr == A: -        temple = [tera[A - 1]] -    else: -        temple = [tera[tl - 1], tera[tl]] -    if sl == 0: -        shrine = [sha[0]] -    elif sr == B: -        shrine = [sha[B - 1]] -    else: -        shrine = [sha[sl - 1], sha[sl]] -    ans = 10**18 -    for t in temple: -        for s in shrine: -            tx = t - x -            sx = s - x -            if tx * sx >= 0: -                a = max(abs(tx), abs(sx)) -            else: -                a = min(2 * abs(tx) + abs(sx), 2 * abs(sx) + abs(tx)) -            ans = min(ans, a) -    res.append(ans) -print(*res, sep="\n") +input = sys.stdin.buffer.readline +sys.setrecursionlimit(10**7) +bl = bisect.bisect_left +A, B, Q = list(map(int, input().split())) +inf = 10**18 +S = [-inf] + [int(eval(input())) for _ in range(A)] + [inf] +T = [-inf] + [int(eval(input())) for _ in range(B)] + [inf] + + +def path(x): +    sl = S[bl(S, x) - 1] +    sr = S[bl(S, x)] +    tl = T[bl(T, x) - 1] +    tr = T[bl(T, x)] +    res = 10**18 +    res = min(res, abs(x - sl) + abs(sl - tl)) +    res = min(res, abs(x - sl) + abs(sl - tr)) +    res = min(res, abs(x - sr) + abs(sr - tr)) +    res = min(res, abs(x - sr) + abs(sr - tl)) +    res = min(res, abs(x - tr) + abs(tr - sl)) +    res = min(res, abs(x - tr) + abs(tr - sr)) +    res = min(res, abs(x - tl) + abs(tl - sl)) +    res = min(res, abs(x - tl) + abs(tl - sr)) +    return res + + +X = [int(eval(input())) for _ in range(Q)] +for x in X: +    print((path(x)))