import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
for _ in range(Q):
    x = int(input())
    sr = min(bisect.bisect_left(S, x), A - 1)
    sl = max(sr - 1, 0)
    tr = min(bisect.bisect_left(T, x), B - 1)
    tl = max(tr - 1, 0)
    print(min(abs(x - S[sl]) + abs(S[sl] - T[tl]),
              abs(x - S[sl]) + abs(S[sl] - T[tr]),
              abs(x - S[sr]) + abs(S[sr] - T[tl]),
              abs(x - S[sr]) + abs(S[sr] - T[tr]),
              abs(x - T[tl]) + abs(T[tl] - S[sl]),
              abs(x - T[tl]) + abs(T[tl] - S[sr]),
              abs(x - T[tr]) + abs(T[tr] - S[sl]),
              abs(x - T[tr]) + abs(T[tr] - S[sr]))) import bisect bisect 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 = [int(input()) for _ in range(A)] S [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [int(input()) for _ in range(B)] T [int(input()) for _ in range(B)] for _ in range(Q):
    x = int(input())
    sr = min(bisect.bisect_left(S, x), A - 1)
    sl = max(sr - 1, 0)
    tr = min(bisect.bisect_left(T, x), B - 1)
    tl = max(tr - 1, 0)
    print(min(abs(x - S[sl]) + abs(S[sl] - T[tl]),
              abs(x - S[sl]) + abs(S[sl] - T[tr]),
              abs(x - S[sr]) + abs(S[sr] - T[tl]),
              abs(x - S[sr]) + abs(S[sr] - T[tr]),
              abs(x - T[tl]) + abs(T[tl] - S[sl]),
              abs(x - T[tl]) + abs(T[tl] - S[sr]),
              abs(x - T[tr]) + abs(T[tr] - S[sl]),
              abs(x - T[tr]) + abs(T[tr] - S[sr]))) _ range(Q) range Q x = int(input()) x int(input()) int input() input sr = min(bisect.bisect_left(S, x), A - 1) sr min(bisect.bisect_left(S, x), A - 1) min bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x A - 1 A 1 sl = max(sr - 1, 0) sl max(sr - 1, 0) max sr - 1 sr 1 0 tr = min(bisect.bisect_left(T, x), B - 1) tr min(bisect.bisect_left(T, x), B - 1) min bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x B - 1 B 1 tl = max(tr - 1, 0) tl max(tr - 1, 0) max tr - 1 tr 1 0 print(min(abs(x - S[sl]) + abs(S[sl] - T[tl]),
              abs(x - S[sl]) + abs(S[sl] - T[tr]),
              abs(x - S[sr]) + abs(S[sr] - T[tl]),
              abs(x - S[sr]) + abs(S[sr] - T[tr]),
              abs(x - T[tl]) + abs(T[tl] - S[sl]),
              abs(x - T[tl]) + abs(T[tl] - S[sr]),
              abs(x - T[tr]) + abs(T[tr] - S[sl]),
              abs(x - T[tr]) + abs(T[tr] - S[sr]))) print min(abs(x - S[sl]) + abs(S[sl] - T[tl]),
              abs(x - S[sl]) + abs(S[sl] - T[tr]),
              abs(x - S[sr]) + abs(S[sr] - T[tl]),
              abs(x - S[sr]) + abs(S[sr] - T[tr]),
              abs(x - T[tl]) + abs(T[tl] - S[sl]),
              abs(x - T[tl]) + abs(T[tl] - S[sr]),
              abs(x - T[tr]) + abs(T[tr] - S[sl]),
              abs(x - T[tr]) + abs(T[tr] - S[sr])) min abs(x - S[sl]) + abs(S[sl] - T[tl]) abs(x - S[sl]) abs x - S[sl] x S[sl] S sl abs(S[sl] - T[tl]) abs S[sl] - T[tl] S[sl] S sl T[tl] T tl abs(x - S[sl]) + abs(S[sl] - T[tr]) abs(x - S[sl]) abs x - S[sl] x S[sl] S sl abs(S[sl] - T[tr]) abs S[sl] - T[tr] S[sl] S sl T[tr] T tr abs(x - S[sr]) + abs(S[sr] - T[tl]) abs(x - S[sr]) abs x - S[sr] x S[sr] S sr abs(S[sr] - T[tl]) abs S[sr] - T[tl] S[sr] S sr T[tl] T tl abs(x - S[sr]) + abs(S[sr] - T[tr]) abs(x - S[sr]) abs x - S[sr] x S[sr] S sr abs(S[sr] - T[tr]) abs S[sr] - T[tr] S[sr] S sr T[tr] T tr abs(x - T[tl]) + abs(T[tl] - S[sl]) abs(x - T[tl]) abs x - T[tl] x T[tl] T tl abs(T[tl] - S[sl]) abs T[tl] - S[sl] T[tl] T tl S[sl] S sl abs(x - T[tl]) + abs(T[tl] - S[sr]) abs(x - T[tl]) abs x - T[tl] x T[tl] T tl abs(T[tl] - S[sr]) abs T[tl] - S[sr] T[tl] T tl S[sr] S sr abs(x - T[tr]) + abs(T[tr] - S[sl]) abs(x - T[tr]) abs x - T[tr] x T[tr] T tr abs(T[tr] - S[sl]) abs T[tr] - S[sl] T[tr] T tr S[sl] S sl abs(x - T[tr]) + abs(T[tr] - S[sr]) abs(x - T[tr]) abs x - T[tr] x T[tr] T tr abs(T[tr] - S[sr]) abs T[tr] - S[sr] T[tr] T tr S[sr] S sr Q = map(int, input().split()) map(int, input().split()) Q T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T A, B, Q = map(int, input().split()) map(int, input().split()) A sl = max(sr - 1, 0) max(sr - 1, 0) sl tr = min(bisect.bisect_left(T, x), B - 1) min(bisect.bisect_left(T, x), B - 1) tr S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S tl = max(tr - 1, 0) max(tr - 1, 0) tl x = int(input()) int(input()) x B, Q = map(int, input().split()) map(int, input().split()) B sr = min(bisect.bisect_left(S, x), A - 1) min(bisect.bisect_left(S, x), A - 1) sr
import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
for _ in range(Q):
    x = int(input())
    sr = min(bisect.bisect_left(S, x), A - 1)
    sl = max(sr - 1, 0)
    tr = min(bisect.bisect_left(T, x), B - 1)
    tl = max(tr - 1, 0)
    print(min(abs(x - S[sl]) + abs(S[sl] - T[tl]),
              abs(x - S[sl]) + abs(S[sl] - T[tr]),
              abs(x - S[sr]) + abs(S[sr] - T[tl]),
              abs(x - S[sr]) + abs(S[sr] - T[tr]),
              abs(x - T[tl]) + abs(T[tl] - S[sl]),
              abs(x - T[tl]) + abs(T[tl] - S[sr]),
              abs(x - T[tr]) + abs(T[tr] - S[sl]),
              abs(x - T[tr]) + abs(T[tr] - S[sr])))
