from bisect import *
A,B,Q=map(int,input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
st = [] # (z, 0or1)0ならs, 1ならt
for i in range(A):
    st.append((s[i], 0))
for i in range(B):
    st.append((t[i], 1))

st.sort(key=lambda x: x[0])
INF = float("inf")

for _ in range(Q):
    x = int(input())
    b_left = bisect_left(st, (x, 0))
    ids = [b_left-1, b_left, b_left+1]
    dists = []
    for idx in ids:
        if 0 <= idx <= A+B-1:
            dists.append((abs(x - st[idx][0]), idx))

    ans = INF
    for start in dists:
        tmp = start[0]
        s_idx = start[1]
        now = st[s_idx][0]
        if st[s_idx][1] == 0: #s
            t_left = bisect_left(t, now)
            additional = []
            for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
        else:
            s_left = bisect_left(s, now)
            additional = []
            for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
    print(ans) from bisect import * 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)] st = [] st [] for i in range(A):
    st.append((s[i], 0)) i range(A) range A st.append((s[i], 0)) st.append st append (s[i], 0) s[i] s i 0 for i in range(B):
    st.append((t[i], 1)) i range(B) range B st.append((t[i], 1)) st.append st append (t[i], 1) t[i] t i 1 st.sort(key=lambda x: x[0]) st.sort st sort key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x INF = float("inf") INF float("inf") float "inf" for _ in range(Q):
    x = int(input())
    b_left = bisect_left(st, (x, 0))
    ids = [b_left-1, b_left, b_left+1]
    dists = []
    for idx in ids:
        if 0 <= idx <= A+B-1:
            dists.append((abs(x - st[idx][0]), idx))

    ans = INF
    for start in dists:
        tmp = start[0]
        s_idx = start[1]
        now = st[s_idx][0]
        if st[s_idx][1] == 0: #s
            t_left = bisect_left(t, now)
            additional = []
            for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
        else:
            s_left = bisect_left(s, now)
            additional = []
            for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input b_left = bisect_left(st, (x, 0)) b_left bisect_left(st, (x, 0)) bisect_left st (x, 0) x 0 ids = [b_left-1, b_left, b_left+1] ids [b_left-1, b_left, b_left+1] b_left-1 b_left 1 b_left b_left+1 b_left 1 dists = [] dists [] for idx in ids:
        if 0 <= idx <= A+B-1:
            dists.append((abs(x - st[idx][0]), idx))

     idx ids if 0 <= idx <= A+B-1:
            dists.append((abs(x - st[idx][0]), idx))

     0 <= idx <= A+B-1 0 <= idx 0 idx A+B-1 A+B A B 1 dists.append((abs(x - st[idx][0]), idx)) dists.append dists append (abs(x - st[idx][0]), idx) abs(x - st[idx][0]) abs x - st[idx][0] x st[idx][0] [idx] st idx 0 idx ans = INF ans INF for start in dists:
        tmp = start[0]
        s_idx = start[1]
        now = st[s_idx][0]
        if st[s_idx][1] == 0: #s
            t_left = bisect_left(t, now)
            additional = []
            for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
        else:
            s_left = bisect_left(s, now)
            additional = []
            for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
     start dists tmp = start[0] tmp start[0] start 0 s_idx = start[1] s_idx start[1] start 1 now = st[s_idx][0] now st[s_idx][0] [s_idx] st s_idx 0 if st[s_idx][1] == 0: #s
            t_left = bisect_left(t, now)
            additional = []
            for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
        else:
            s_left = bisect_left(s, now)
            additional = []
            for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
     st[s_idx][1] == 0 st[s_idx][1] [s_idx] st s_idx 1 0 t_left = bisect_left(t, now) t_left bisect_left(t, now) bisect_left t now additional = [] additional [] for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
             nxt [t_left-1, t_left, t_left+1] t_left-1 t_left 1 t_left t_left+1 t_left 1 if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
             0<=nxt<=B-1 0<=nxt 0 nxt B-1 B 1 additional.append(abs(now - t[nxt])) additional.append additional append abs(now - t[nxt]) abs now - t[nxt] now t[nxt] t nxt delta = min(additional) delta min(additional) min additional ans = min(ans, tmp+delta) ans min(ans, tmp+delta) min ans tmp+delta tmp delta s_left = bisect_left(s, now) s_left bisect_left(s, now) bisect_left s now additional = [] additional [] for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
             nxt [s_left-1, s_left, s_left+1] s_left-1 s_left 1 s_left s_left+1 s_left 1 if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
             0 <= nxt <= A-1 0 <= nxt 0 nxt A-1 A 1 additional.append(abs(now - s[nxt])) additional.append additional append abs(now - s[nxt]) abs now - s[nxt] now s[nxt] s nxt delta = min(additional) delta min(additional) min additional ans = min(ans, tmp+delta) ans min(ans, tmp+delta) min ans tmp+delta tmp delta print(ans) print ans t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t B,Q=map(int,input().split()) map(int,input().split()) B A,B,Q=map(int,input().split()) map(int,input().split()) A additional = [] [] additional tmp = start[0] start[0] tmp st = [] [] st s_left = bisect_left(s, now) bisect_left(s, now) s_left additional = [] [] additional s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s INF = float("inf") float("inf") INF b_left = bisect_left(st, (x, 0)) bisect_left(st, (x, 0)) b_left ans = INF INF ans dists = [] [] dists now = st[s_idx][0] st[s_idx][0] now Q=map(int,input().split()) map(int,input().split()) Q s_idx = start[1] start[1] s_idx ans = min(ans, tmp+delta) min(ans, tmp+delta) ans ans = min(ans, tmp+delta) min(ans, tmp+delta) ans delta = min(additional) min(additional) delta ids = [b_left-1, b_left, b_left+1] [b_left-1, b_left, b_left+1] ids delta = min(additional) min(additional) delta x = int(input()) int(input()) x t_left = bisect_left(t, now) bisect_left(t, now) t_left
from bisect import *
A,B,Q=map(int,input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
st = [] # (z, 0or1)0ならs, 1ならt
for i in range(A):
    st.append((s[i], 0))
for i in range(B):
    st.append((t[i], 1))

st.sort(key=lambda x: x[0])
INF = float("inf")

for _ in range(Q):
    x = int(input())
    b_left = bisect_left(st, (x, 0))
    ids = [b_left-1, b_left, b_left+1]
    dists = []
    for idx in ids:
        if 0 <= idx <= A+B-1:
            dists.append((abs(x - st[idx][0]), idx))

    ans = INF
    for start in dists:
        tmp = start[0]
        s_idx = start[1]
        now = st[s_idx][0]
        if st[s_idx][1] == 0: #s
            t_left = bisect_left(t, now)
            additional = []
            for nxt in [t_left-1, t_left, t_left+1]:
                if 0<=nxt<=B-1:
                    additional.append(abs(now - t[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
        else:
            s_left = bisect_left(s, now)
            additional = []
            for nxt in [s_left-1, s_left, s_left+1]:
                if 0 <= nxt <= A-1:
                    additional.append(abs(now - s[nxt]))
            delta = min(additional)
            ans = min(ans, tmp+delta)
    print(ans)