import sys
import bisect
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
bl = bisect.bisect_left

A, B, Q = map(int, input().split())
inf = 10**18
S = [-inf]+[int(input()) for _ in range(A)]+[inf]
T = [-inf]+[int(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(input()) for _ in range(Q)]
for x in X:
    print(path(x)) import sys sys import bisect bisect input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 bl = bisect.bisect_left bl bisect.bisect_left bisect 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 S = [-inf]+[int(input()) for _ in range(A)]+[inf] S [-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 T = [-inf]+[int(input()) for _ in range(B)]+[inf] T [-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 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 path sl = S[bl(S, x) - 1] sl S[bl(S, x) - 1] S bl(S, x) - 1 bl(S, x) bl S x 1 sr = S[bl(S, x)] sr S[bl(S, x)] S bl(S, x) bl S x tl = T[bl(T, x) - 1] tl T[bl(T, x) - 1] T bl(T, x) - 1 bl(T, x) bl T x 1 tr = T[bl(T, x)] tr T[bl(T, x)] T bl(T, x) bl T x res = 10 ** 18 res 10 ** 18 10 18 res = min(res, abs(x - sl) + abs(sl - tl)) res min(res, abs(x - sl) + abs(sl - tl)) min res abs(x - sl) + abs(sl - tl) abs(x - sl) abs x - sl x sl abs(sl - tl) abs sl - tl sl tl res = min(res, abs(x - sl) + abs(sl - tr)) res min(res, abs(x - sl) + abs(sl - tr)) min res abs(x - sl) + abs(sl - tr) abs(x - sl) abs x - sl x sl abs(sl - tr) abs sl - tr sl tr res = min(res, abs(x - sr) + abs(sr - tr)) res min(res, abs(x - sr) + abs(sr - tr)) min res abs(x - sr) + abs(sr - tr) abs(x - sr) abs x - sr x sr abs(sr - tr) abs sr - tr sr tr res = min(res, abs(x - sr) + abs(sr - tl)) res min(res, abs(x - sr) + abs(sr - tl)) min res abs(x - sr) + abs(sr - tl) abs(x - sr) abs x - sr x sr abs(sr - tl) abs sr - tl sr tl res = min(res, abs(x - tr) + abs(tr - sl)) res min(res, abs(x - tr) + abs(tr - sl)) min res abs(x - tr) + abs(tr - sl) abs(x - tr) abs x - tr x tr abs(tr - sl) abs tr - sl tr sl res = min(res, abs(x - tr) + abs(tr - sr)) res min(res, abs(x - tr) + abs(tr - sr)) min res abs(x - tr) + abs(tr - sr) abs(x - tr) abs x - tr x tr abs(tr - sr) abs tr - sr tr sr res = min(res, abs(x - tl) + abs(tl - sl)) res min(res, abs(x - tl) + abs(tl - sl)) min res abs(x - tl) + abs(tl - sl) abs(x - tl) abs x - tl x tl abs(tl - sl) abs tl - sl tl sl res = min(res, abs(x - tl) + abs(tl - sr)) res min(res, abs(x - tl) + abs(tl - sr)) min res abs(x - tl) + abs(tl - sr) abs(x - tl) abs x - tl x tl abs(tl - sr) abs tl - sr tl sr return res res x x int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input X = [int(input()) for _ in range(Q)] X [int(input()) for _ in range(Q)] for x in X:
    print(path(x)) x X print(path(x)) print path(x) path x S = [-inf]+[int(input()) for _ in range(A)]+[inf] [-inf]+[int(input()) for _ in range(A)]+[inf] S T = [-inf]+[int(input()) for _ in range(B)]+[inf] [-inf]+[int(input()) for _ in range(B)]+[inf] T inf = 10**18 10**18 inf B, Q = map(int, input().split()) map(int, input().split()) B X = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] X input = sys.stdin.buffer.readline sys.stdin.buffer.readline input 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 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 path bl = bisect.bisect_left bisect.bisect_left bl A, B, Q = map(int, input().split()) map(int, input().split()) A Q = map(int, input().split()) map(int, input().split()) Q
import sys
import bisect
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
bl = bisect.bisect_left

A, B, Q = map(int, input().split())
inf = 10**18
S = [-inf]+[int(input()) for _ in range(A)]+[inf]
T = [-inf]+[int(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(input()) for _ in range(Q)]
for x in X:
    print(path(x))