import bisect
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]

for q in range(Q):
    x = int(input())
    y1 = bisect.bisect_right(s, x)
    y2 = bisect.bisect_right(t, x)
    res = INF
    # 最も近い神社の候補２つ
    for sx in [s[y1 - 1], s[y1]]:
        # 最も近い寺の候補２つ
        for tx in [t[y2 - 1], t[y2]]:
            # 神社、寺の順で訪れる場合
            d1 = abs(sx - x) + abs(tx - sx)
            # 寺、神社の順で訪れる場合
            d2 = abs(tx - x) + abs(sx - tx)
            res = min(res, d1, d2)
    print(res) import bisect bisect 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 for q in range(Q):
    x = int(input())
    y1 = bisect.bisect_right(s, x)
    y2 = bisect.bisect_right(t, x)
    res = INF
    # 最も近い神社の候補２つ
    for sx in [s[y1 - 1], s[y1]]:
        # 最も近い寺の候補２つ
        for tx in [t[y2 - 1], t[y2]]:
            # 神社、寺の順で訪れる場合
            d1 = abs(sx - x) + abs(tx - sx)
            # 寺、神社の順で訪れる場合
            d2 = abs(tx - x) + abs(sx - tx)
            res = min(res, d1, d2)
    print(res) q range(Q) range Q x = int(input()) x int(input()) int input() input y1 = bisect.bisect_right(s, x) y1 bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x y2 = bisect.bisect_right(t, x) y2 bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x res = INF res INF for sx in [s[y1 - 1], s[y1]]:
        # 最も近い寺の候補２つ
        for tx in [t[y2 - 1], t[y2]]:
            # 神社、寺の順で訪れる場合
            d1 = abs(sx - x) + abs(tx - sx)
            # 寺、神社の順で訪れる場合
            d2 = abs(tx - x) + abs(sx - tx)
            res = min(res, d1, d2)
     sx [s[y1 - 1], s[y1]] s[y1 - 1] s y1 - 1 y1 1 s[y1] s y1 for tx in [t[y2 - 1], t[y2]]:
            # 神社、寺の順で訪れる場合
            d1 = abs(sx - x) + abs(tx - sx)
            # 寺、神社の順で訪れる場合
            d2 = abs(tx - x) + abs(sx - tx)
            res = min(res, d1, d2)
     tx [t[y2 - 1], t[y2]] t[y2 - 1] t y2 - 1 y2 1 t[y2] t y2 d1 = abs(sx - x) + abs(tx - sx) d1 abs(sx - x) + abs(tx - sx) abs(sx - x) abs sx - x sx x abs(tx - sx) abs tx - sx tx sx d2 = abs(tx - x) + abs(sx - tx) d2 abs(tx - x) + abs(sx - tx) abs(tx - x) abs tx - x tx x abs(sx - tx) abs sx - tx sx tx res = min(res, d1, d2) res min(res, d1, d2) min res d1 d2 print(res) print res Q = map(int, input().split()) map(int, input().split()) Q x = int(input()) int(input()) x d1 = abs(sx - x) + abs(tx - sx) abs(sx - x) + abs(tx - sx) d1 res = INF INF res res = min(res, d1, d2) min(res, d1, d2) res INF = 10 ** 18 10 ** 18 INF y2 = bisect.bisect_right(t, x) bisect.bisect_right(t, x) y2 d2 = abs(tx - x) + abs(sx - tx) abs(tx - x) + abs(sx - tx) d2 s = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] s A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B t = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] t y1 = bisect.bisect_right(s, x) bisect.bisect_right(s, x) y1
import bisect
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]

for q in range(Q):
    x = int(input())
    y1 = bisect.bisect_right(s, x)
    y2 = bisect.bisect_right(t, x)
    res = INF
    # 最も近い神社の候補２つ
    for sx in [s[y1 - 1], s[y1]]:
        # 最も近い寺の候補２つ
        for tx in [t[y2 - 1], t[y2]]:
            # 神社、寺の順で訪れる場合
            d1 = abs(sx - x) + abs(tx - sx)
            # 寺、神社の順で訪れる場合
            d2 = abs(tx - x) + abs(sx - tx)
            res = min(res, d1, d2)
    print(res)
