import bisect
INF = 10**13
A, B, Q = map(int, input().split())
S = [int(input()) for a in range(A)]
T = [int(input()) for b in range(B)]
for q in range(Q):
    x = int(input())
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    Sq = [S[max(si-1, 0)], S[min(si, A-1)]]
    Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]]
    ans = float('inf')
    for i in range(2):
        for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

    print(ans) import bisect bisect INF = 10**13 INF 10**13 10 13 A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q int(input()) for a in range(A) for a in range(A) a range(A) range A for a in range(A) int(input()) int input() input S = [int(input()) for a in range(A)] S [int(input()) for a in range(A)] int(input()) for b in range(B) for b in range(B) b range(B) range B for b in range(B) int(input()) int input() input T = [int(input()) for b in range(B)] T [int(input()) for b in range(B)] for q in range(Q):
    x = int(input())
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    Sq = [S[max(si-1, 0)], S[min(si, A-1)]]
    Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]]
    ans = float('inf')
    for i in range(2):
        for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

    print(ans) q range(Q) range Q x = int(input()) x int(input()) int input() input si = bisect.bisect_left(S, x) si bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x ti = bisect.bisect_left(T, x) ti bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x Sq = [S[max(si-1, 0)], S[min(si, A-1)]] Sq [S[max(si-1, 0)], S[min(si, A-1)]] S[max(si-1, 0)] S max(si-1, 0) max si-1 si 1 0 S[min(si, A-1)] S min(si, A-1) min si A-1 A 1 Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]] Tq [T[max(ti-1, 0)], T[min(ti, B-1)]] T[max(ti-1, 0)] T max(ti-1, 0) max ti-1 ti 1 0 T[min(ti, B-1)] T min(ti, B-1) min ti B-1 B 1 ans = float('inf') ans float('inf') float 'inf' for i in range(2):
        for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

     i range(2) range 2 for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

     j range(2) range 2 s = Sq[i] s Sq[i] Sq i t = Tq[j] t Tq[j] Tq j if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

     (s < x and t < x) or (x < s and x < t) s < x and t < x s < x s x t < x t x x < s and x < t x < s x s x < t x t xs, tx = abs(x-s), abs(x-t) xs abs(x-s) abs x-s x s tx abs(x-t) abs x-t x t ans = min(ans, max(xs, tx)) ans min(ans, max(xs, tx)) min ans max(xs, tx) max xs tx xs, tx = abs(s-x), abs(t-x) xs abs(s-x) abs s-x s x tx abs(t-x) abs t-x t x ans = min(ans, min(xs, tx)*2 + max(xs, tx)) ans min(ans, min(xs, tx)*2 + max(xs, tx)) min ans min(xs, tx)*2 + max(xs, tx) min(xs, tx)*2 min(xs, tx) min xs tx 2 max(xs, tx) max xs tx print(ans) print ans x = int(input()) int(input()) x ti = bisect.bisect_left(T, x) bisect.bisect_left(T, x) ti B, Q = map(int, input().split()) map(int, input().split()) B Q = map(int, input().split()) map(int, input().split()) Q S = [int(input()) for a in range(A)] [int(input()) for a in range(A)] S xs, tx = abs(s-x), abs(t-x) abs(s-x) xs T = [int(input()) for b in range(B)] [int(input()) for b in range(B)] T ans = min(ans, max(xs, tx)) min(ans, max(xs, tx)) ans s = Sq[i] Sq[i] s ans = float('inf') float('inf') ans ans = min(ans, min(xs, tx)*2 + max(xs, tx)) min(ans, min(xs, tx)*2 + max(xs, tx)) ans INF = 10**13 10**13 INF A, B, Q = map(int, input().split()) map(int, input().split()) A xs, tx = abs(x-s), abs(x-t) abs(x-s) xs tx = abs(x-s), abs(x-t) abs(x-t) tx t = Tq[j] Tq[j] t Sq = [S[max(si-1, 0)], S[min(si, A-1)]] [S[max(si-1, 0)], S[min(si, A-1)]] Sq tx = abs(s-x), abs(t-x) abs(t-x) tx si = bisect.bisect_left(S, x) bisect.bisect_left(S, x) si Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]] [T[max(ti-1, 0)], T[min(ti, B-1)]] Tq
import bisect
INF = 10**13
A, B, Q = map(int, input().split())
S = [int(input()) for a in range(A)]
T = [int(input()) for b in range(B)]
for q in range(Q):
    x = int(input())
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    Sq = [S[max(si-1, 0)], S[min(si, A-1)]]
    Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]]
    ans = float('inf')
    for i in range(2):
        for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

    print(ans)
