from bisect import bisect_left
import sys
input = sys.stdin.readline

INF = 10**18

A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]

for _ in range(Q):
    x = int(input())
    si = bisect_left(S,x)
    ti = bisect_left(T,x)
    res = INF
    res = min(res, max(S[si] - x, T[ti] - x))
    res = min(res, max(x - S[si - 1], x - T[ti - 1]))
    res = min(res, x + T[ti] - 2 * S[si - 1])
    res = min(res, -x + 2 * T[ti] - S[si - 1])
    res = min(res, x + S[si] - 2 * T[ti - 1])
    res = min(res, -x + 2 * S[si] - T[ti - 1])
    print(res) from bisect import bisect_left import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = 10**18 INF 10**18 10 18 A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q 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 _ in range(Q):
    x = int(input())
    si = bisect_left(S,x)
    ti = bisect_left(T,x)
    res = INF
    res = min(res, max(S[si] - x, T[ti] - x))
    res = min(res, max(x - S[si - 1], x - T[ti - 1]))
    res = min(res, x + T[ti] - 2 * S[si - 1])
    res = min(res, -x + 2 * T[ti] - S[si - 1])
    res = min(res, x + S[si] - 2 * T[ti - 1])
    res = min(res, -x + 2 * S[si] - T[ti - 1])
    print(res) _ range(Q) range Q x = int(input()) x int(input()) int input() input si = bisect_left(S,x) si bisect_left(S,x) bisect_left S x ti = bisect_left(T,x) ti bisect_left(T,x) bisect_left T x res = INF res INF res = min(res, max(S[si] - x, T[ti] - x)) res min(res, max(S[si] - x, T[ti] - x)) min res max(S[si] - x, T[ti] - x) max S[si] - x S[si] S si x T[ti] - x T[ti] T ti x res = min(res, max(x - S[si - 1], x - T[ti - 1])) res min(res, max(x - S[si - 1], x - T[ti - 1])) min res max(x - S[si - 1], x - T[ti - 1]) max x - S[si - 1] x S[si - 1] S si - 1 si 1 x - T[ti - 1] x T[ti - 1] T ti - 1 ti 1 res = min(res, x + T[ti] - 2 * S[si - 1]) res min(res, x + T[ti] - 2 * S[si - 1]) min res x + T[ti] - 2 * S[si - 1] x + T[ti] x T[ti] T ti 2 * S[si - 1] 2 S[si - 1] S si - 1 si 1 res = min(res, -x + 2 * T[ti] - S[si - 1]) res min(res, -x + 2 * T[ti] - S[si - 1]) min res -x + 2 * T[ti] - S[si - 1] -x + 2 * T[ti] -x x 2 * T[ti] 2 T[ti] T ti S[si - 1] S si - 1 si 1 res = min(res, x + S[si] - 2 * T[ti - 1]) res min(res, x + S[si] - 2 * T[ti - 1]) min res x + S[si] - 2 * T[ti - 1] x + S[si] x S[si] S si 2 * T[ti - 1] 2 T[ti - 1] T ti - 1 ti 1 res = min(res, -x + 2 * S[si] - T[ti - 1]) res min(res, -x + 2 * S[si] - T[ti - 1]) min res -x + 2 * S[si] - T[ti - 1] -x + 2 * S[si] -x x 2 * S[si] 2 S[si] S si T[ti - 1] T ti - 1 ti 1 print(res) print res INF = 10**18 10**18 INF x = int(input()) int(input()) x input = sys.stdin.readline sys.stdin.readline input A, B, Q = map(int, input().split()) map(int, input().split()) A T = [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] + [INF] T res = min(res, max(S[si] - x, T[ti] - x)) min(res, max(S[si] - x, T[ti] - x)) res res = min(res, max(x - S[si - 1], x - T[ti - 1])) min(res, max(x - S[si - 1], x - T[ti - 1])) res res = min(res, x + T[ti] - 2 * S[si - 1]) min(res, x + T[ti] - 2 * S[si - 1]) res Q = map(int, input().split()) map(int, input().split()) Q ti = bisect_left(T,x) bisect_left(T,x) ti S = [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] + [INF] S res = min(res, -x + 2 * T[ti] - S[si - 1]) min(res, -x + 2 * T[ti] - S[si - 1]) res res = min(res, -x + 2 * S[si] - T[ti - 1]) min(res, -x + 2 * S[si] - T[ti - 1]) res res = INF INF res B, Q = map(int, input().split()) map(int, input().split()) B si = bisect_left(S,x) bisect_left(S,x) si res = min(res, x + S[si] - 2 * T[ti - 1]) min(res, x + S[si] - 2 * T[ti - 1]) res
from bisect import bisect_left
import sys
input = sys.stdin.readline

INF = 10**18

A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]

for _ in range(Q):
    x = int(input())
    si = bisect_left(S,x)
    ti = bisect_left(T,x)
    res = INF
    res = min(res, max(S[si] - x, T[ti] - x))
    res = min(res, max(x - S[si - 1], x - T[ti - 1]))
    res = min(res, x + T[ti] - 2 * S[si - 1])
    res = min(res, -x + 2 * T[ti] - S[si - 1])
    res = min(res, x + S[si] - 2 * T[ti - 1])
    res = min(res, -x + 2 * S[si] - T[ti - 1])
    print(res)