A, B, Q = map(int, input().split())

MY_INF = 10 ** 18

s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]

s = [-MY_INF] + s + [MY_INF]
t = [-MY_INF] + t + [MY_INF]

import bisect

for i, xi in enumerate(x):
    ans = 10 ** 18
    #
    # s -> r
    idx_s = bisect.bisect_left(s, xi)
    #
    s_l = s[idx_s - 1]
    idx_tl = bisect.bisect_left(t, s_l)
    #
    t_ll = t[idx_tl - 1]
    ans_tmp = abs(s_l - xi) + abs(t_ll - s_l)
    ans = min(ans, ans_tmp)
    t_lr = t[idx_tl]
    ans_tmp = abs(s_l - xi) + abs(t_lr - s_l)
    ans = min(ans, ans_tmp)
    #
    s_r = s[idx_s]
    idx_tr = bisect.bisect_left(t, s_r)
    #
    t_rl = t[idx_tr - 1]
    ans_tmp = abs(s_r - xi) + abs(t_rl - s_r)
    ans = min(ans, ans_tmp)
    #
    t_rr = t[idx_tr]
    ans_tmp = abs(s_r - xi) + abs(t_rr - s_r)
    ans = min(ans, ans_tmp)
    #
    # t -> r
    idx_t = bisect.bisect_left(t, xi)
    #
    t_l = t[idx_t - 1]
    idx_sl = bisect.bisect_left(s, t_l)
    #
    s_ll = s[idx_sl - 1]
    ans_tmp = abs(t_l - xi) + abs(s_ll - t_l)
    ans = min(ans, ans_tmp)
    s_lr = s[idx_sl]
    ans_tmp = abs(t_l - xi) + abs(s_lr - t_l)
    ans = min(ans, ans_tmp)
    #
    t_r = t[idx_t]
    idx_sr = bisect.bisect_left(s, t_r)
    #
    s_rl = s[idx_sr - 1]
    ans_tmp = abs(t_r - xi) + abs(s_rl - t_r)
    ans = min(ans, ans_tmp)
    #
    s_rr = s[idx_sr]
    ans_tmp = abs(t_r - xi) + abs(s_rr - t_r)
    ans = min(ans, ans_tmp)
    #
    print(ans) A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q MY_INF = 10 ** 18 MY_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 = [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)] 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)] s = [-MY_INF] + s + [MY_INF] s [-MY_INF] + s + [MY_INF] [-MY_INF] + s [-MY_INF] -MY_INF MY_INF s [MY_INF] MY_INF t = [-MY_INF] + t + [MY_INF] t [-MY_INF] + t + [MY_INF] [-MY_INF] + t [-MY_INF] -MY_INF MY_INF t [MY_INF] MY_INF import bisect bisect for i, xi in enumerate(x):
    ans = 10 ** 18
    #
    # s -> r
    idx_s = bisect.bisect_left(s, xi)
    #
    s_l = s[idx_s - 1]
    idx_tl = bisect.bisect_left(t, s_l)
    #
    t_ll = t[idx_tl - 1]
    ans_tmp = abs(s_l - xi) + abs(t_ll - s_l)
    ans = min(ans, ans_tmp)
    t_lr = t[idx_tl]
    ans_tmp = abs(s_l - xi) + abs(t_lr - s_l)
    ans = min(ans, ans_tmp)
    #
    s_r = s[idx_s]
    idx_tr = bisect.bisect_left(t, s_r)
    #
    t_rl = t[idx_tr - 1]
    ans_tmp = abs(s_r - xi) + abs(t_rl - s_r)
    ans = min(ans, ans_tmp)
    #
    t_rr = t[idx_tr]
    ans_tmp = abs(s_r - xi) + abs(t_rr - s_r)
    ans = min(ans, ans_tmp)
    #
    # t -> r
    idx_t = bisect.bisect_left(t, xi)
    #
    t_l = t[idx_t - 1]
    idx_sl = bisect.bisect_left(s, t_l)
    #
    s_ll = s[idx_sl - 1]
    ans_tmp = abs(t_l - xi) + abs(s_ll - t_l)
    ans = min(ans, ans_tmp)
    s_lr = s[idx_sl]
    ans_tmp = abs(t_l - xi) + abs(s_lr - t_l)
    ans = min(ans, ans_tmp)
    #
    t_r = t[idx_t]
    idx_sr = bisect.bisect_left(s, t_r)
    #
    s_rl = s[idx_sr - 1]
    ans_tmp = abs(t_r - xi) + abs(s_rl - t_r)
    ans = min(ans, ans_tmp)
    #
    s_rr = s[idx_sr]
    ans_tmp = abs(t_r - xi) + abs(s_rr - t_r)
    ans = min(ans, ans_tmp)
    #
    print(ans) i xi enumerate(x) enumerate x ans = 10 ** 18 ans 10 ** 18 10 18 idx_s = bisect.bisect_left(s, xi) idx_s bisect.bisect_left(s, xi) bisect.bisect_left bisect bisect_left s xi s_l = s[idx_s - 1] s_l s[idx_s - 1] s idx_s - 1 idx_s 1 idx_tl = bisect.bisect_left(t, s_l) idx_tl bisect.bisect_left(t, s_l) bisect.bisect_left bisect bisect_left t s_l t_ll = t[idx_tl - 1] t_ll t[idx_tl - 1] t idx_tl - 1 idx_tl 1 ans_tmp = abs(s_l - xi) + abs(t_ll - s_l) ans_tmp abs(s_l - xi) + abs(t_ll - s_l) abs(s_l - xi) abs s_l - xi s_l xi abs(t_ll - s_l) abs t_ll - s_l t_ll s_l ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp t_lr = t[idx_tl] t_lr t[idx_tl] t idx_tl ans_tmp = abs(s_l - xi) + abs(t_lr - s_l) ans_tmp abs(s_l - xi) + abs(t_lr - s_l) abs(s_l - xi) abs s_l - xi s_l xi abs(t_lr - s_l) abs t_lr - s_l t_lr s_l ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp s_r = s[idx_s] s_r s[idx_s] s idx_s idx_tr = bisect.bisect_left(t, s_r) idx_tr bisect.bisect_left(t, s_r) bisect.bisect_left bisect bisect_left t s_r t_rl = t[idx_tr - 1] t_rl t[idx_tr - 1] t idx_tr - 1 idx_tr 1 ans_tmp = abs(s_r - xi) + abs(t_rl - s_r) ans_tmp abs(s_r - xi) + abs(t_rl - s_r) abs(s_r - xi) abs s_r - xi s_r xi abs(t_rl - s_r) abs t_rl - s_r t_rl s_r ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp t_rr = t[idx_tr] t_rr t[idx_tr] t idx_tr ans_tmp = abs(s_r - xi) + abs(t_rr - s_r) ans_tmp abs(s_r - xi) + abs(t_rr - s_r) abs(s_r - xi) abs s_r - xi s_r xi abs(t_rr - s_r) abs t_rr - s_r t_rr s_r ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp idx_t = bisect.bisect_left(t, xi) idx_t bisect.bisect_left(t, xi) bisect.bisect_left bisect bisect_left t xi t_l = t[idx_t - 1] t_l t[idx_t - 1] t idx_t - 1 idx_t 1 idx_sl = bisect.bisect_left(s, t_l) idx_sl bisect.bisect_left(s, t_l) bisect.bisect_left bisect bisect_left s t_l s_ll = s[idx_sl - 1] s_ll s[idx_sl - 1] s idx_sl - 1 idx_sl 1 ans_tmp = abs(t_l - xi) + abs(s_ll - t_l) ans_tmp abs(t_l - xi) + abs(s_ll - t_l) abs(t_l - xi) abs t_l - xi t_l xi abs(s_ll - t_l) abs s_ll - t_l s_ll t_l ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp s_lr = s[idx_sl] s_lr s[idx_sl] s idx_sl ans_tmp = abs(t_l - xi) + abs(s_lr - t_l) ans_tmp abs(t_l - xi) + abs(s_lr - t_l) abs(t_l - xi) abs t_l - xi t_l xi abs(s_lr - t_l) abs s_lr - t_l s_lr t_l ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp t_r = t[idx_t] t_r t[idx_t] t idx_t idx_sr = bisect.bisect_left(s, t_r) idx_sr bisect.bisect_left(s, t_r) bisect.bisect_left bisect bisect_left s t_r s_rl = s[idx_sr - 1] s_rl s[idx_sr - 1] s idx_sr - 1 idx_sr 1 ans_tmp = abs(t_r - xi) + abs(s_rl - t_r) ans_tmp abs(t_r - xi) + abs(s_rl - t_r) abs(t_r - xi) abs t_r - xi t_r xi abs(s_rl - t_r) abs s_rl - t_r s_rl t_r ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp s_rr = s[idx_sr] s_rr s[idx_sr] s idx_sr ans_tmp = abs(t_r - xi) + abs(s_rr - t_r) ans_tmp abs(t_r - xi) + abs(s_rr - t_r) abs(t_r - xi) abs t_r - xi t_r xi abs(s_rr - t_r) abs s_rr - t_r s_rr t_r ans = min(ans, ans_tmp) ans min(ans, ans_tmp) min ans ans_tmp print(ans) print ans t = [-MY_INF] + t + [MY_INF] [-MY_INF] + t + [MY_INF] t ans = min(ans, ans_tmp) min(ans, ans_tmp) ans s = [-MY_INF] + s + [MY_INF] [-MY_INF] + s + [MY_INF] s ans_tmp = abs(s_l - xi) + abs(t_lr - s_l) abs(s_l - xi) + abs(t_lr - s_l) ans_tmp ans = min(ans, ans_tmp) min(ans, ans_tmp) ans s_ll = s[idx_sl - 1] s[idx_sl - 1] s_ll t_r = t[idx_t] t[idx_t] t_r ans = min(ans, ans_tmp) min(ans, ans_tmp) ans idx_t = bisect.bisect_left(t, xi) bisect.bisect_left(t, xi) idx_t t_rr = t[idx_tr] t[idx_tr] t_rr s_lr = s[idx_sl] s[idx_sl] s_lr idx_sr = bisect.bisect_left(s, t_r) bisect.bisect_left(s, t_r) idx_sr s_rr = s[idx_sr] s[idx_sr] s_rr ans_tmp = abs(t_l - xi) + abs(s_ll - t_l) abs(t_l - xi) + abs(s_ll - t_l) ans_tmp ans_tmp = abs(t_l - xi) + abs(s_lr - t_l) abs(t_l - xi) + abs(s_lr - t_l) ans_tmp ans_tmp = abs(t_r - xi) + abs(s_rr - t_r) abs(t_r - xi) + abs(s_rr - t_r) ans_tmp ans = min(ans, ans_tmp) min(ans, ans_tmp) ans ans = min(ans, ans_tmp) min(ans, ans_tmp) ans t_ll = t[idx_tl - 1] t[idx_tl - 1] t_ll s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s idx_s = bisect.bisect_left(s, xi) bisect.bisect_left(s, xi) idx_s idx_tl = bisect.bisect_left(t, s_l) bisect.bisect_left(t, s_l) idx_tl t_lr = t[idx_tl] t[idx_tl] t_lr idx_tr = bisect.bisect_left(t, s_r) bisect.bisect_left(t, s_r) idx_tr 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 ans = min(ans, ans_tmp) min(ans, ans_tmp) ans ans = min(ans, ans_tmp) min(ans, ans_tmp) ans s_l = s[idx_s - 1] s[idx_s - 1] s_l MY_INF = 10 ** 18 10 ** 18 MY_INF ans_tmp = abs(s_l - xi) + abs(t_ll - s_l) abs(s_l - xi) + abs(t_ll - s_l) ans_tmp t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t ans_tmp = abs(t_r - xi) + abs(s_rl - t_r) abs(t_r - xi) + abs(s_rl - t_r) ans_tmp Q = map(int, input().split()) map(int, input().split()) Q A, B, Q = map(int, input().split()) map(int, input().split()) A ans = min(ans, ans_tmp) min(ans, ans_tmp) ans ans_tmp = abs(s_r - xi) + abs(t_rl - s_r) abs(s_r - xi) + abs(t_rl - s_r) ans_tmp idx_sl = bisect.bisect_left(s, t_l) bisect.bisect_left(s, t_l) idx_sl s_r = s[idx_s] s[idx_s] s_r ans_tmp = abs(s_r - xi) + abs(t_rr - s_r) abs(s_r - xi) + abs(t_rr - s_r) ans_tmp s_rl = s[idx_sr - 1] s[idx_sr - 1] s_rl t_rl = t[idx_tr - 1] t[idx_tr - 1] t_rl ans = 10 ** 18 10 ** 18 ans t_l = t[idx_t - 1] t[idx_t - 1] t_l
A, B, Q = map(int, input().split())

MY_INF = 10 ** 18

s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]

s = [-MY_INF] + s + [MY_INF]
t = [-MY_INF] + t + [MY_INF]

import bisect

for i, xi in enumerate(x):
    ans = 10 ** 18
    #
    # s -> r
    idx_s = bisect.bisect_left(s, xi)
    #
    s_l = s[idx_s - 1]
    idx_tl = bisect.bisect_left(t, s_l)
    #
    t_ll = t[idx_tl - 1]
    ans_tmp = abs(s_l - xi) + abs(t_ll - s_l)
    ans = min(ans, ans_tmp)
    t_lr = t[idx_tl]
    ans_tmp = abs(s_l - xi) + abs(t_lr - s_l)
    ans = min(ans, ans_tmp)
    #
    s_r = s[idx_s]
    idx_tr = bisect.bisect_left(t, s_r)
    #
    t_rl = t[idx_tr - 1]
    ans_tmp = abs(s_r - xi) + abs(t_rl - s_r)
    ans = min(ans, ans_tmp)
    #
    t_rr = t[idx_tr]
    ans_tmp = abs(s_r - xi) + abs(t_rr - s_r)
    ans = min(ans, ans_tmp)
    #
    # t -> r
    idx_t = bisect.bisect_left(t, xi)
    #
    t_l = t[idx_t - 1]
    idx_sl = bisect.bisect_left(s, t_l)
    #
    s_ll = s[idx_sl - 1]
    ans_tmp = abs(t_l - xi) + abs(s_ll - t_l)
    ans = min(ans, ans_tmp)
    s_lr = s[idx_sl]
    ans_tmp = abs(t_l - xi) + abs(s_lr - t_l)
    ans = min(ans, ans_tmp)
    #
    t_r = t[idx_t]
    idx_sr = bisect.bisect_left(s, t_r)
    #
    s_rl = s[idx_sr - 1]
    ans_tmp = abs(t_r - xi) + abs(s_rl - t_r)
    ans = min(ans, ans_tmp)
    #
    s_rr = s[idx_sr]
    ans_tmp = abs(t_r - xi) + abs(s_rr - t_r)
    ans = min(ans, ans_tmp)
    #
    print(ans)
