from bisect import bisect

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

S = [int(input()) for i in range(A)]

T = [int(input()) for i in range(B)]

qs = [int(input()) for i in range(Q)]



st = []

for s in S:

    ti = bisect(T,s)

    if ti == 0:

        st.append(abs(s-T[0]))

    elif ti == B:

        st.append(abs(s-T[-1]))

    else:

        tmp = min(abs(s-T[ti-1]), abs(s-T[ti]))

        st.append(tmp)



ts = []

for t in T:

    si = bisect(S,t)

    if si == 0:

        ts.append(abs(t-S[0]))

    elif si == A:

        ts.append(abs(t-S[-1]))

    else:

        tmp = min(abs(t-S[si-1]), abs(t-S[si]))

        ts.append(tmp)



ans = []

for q in qs:

    si = bisect(S,q)

    if si == 0:

        a = abs(q-S[0]) + st[0]

    elif si == A:

        a = abs(q-S[-1]) + st[-1]

    else:

        a = min(abs(q-S[si-1]) + st[si-1], abs(q-S[si]) + st[si])



    ti = bisect(T,q)

    if ti == 0:

        b = abs(q-T[0]) + ts[0]

    elif ti == B:

        b = abs(q-T[-1]) + ts[-1]

    else:

        b = min(abs(q-T[ti-1]) + ts[ti-1], abs(q-T[ti]) + ts[ti])



    ans.append(min(a,b))



print(*ans, sep='\n')

import sys

input = sys.stdin.readline

from bisect import bisect



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

S = [int(input()) for i in range(A)]

T = [int(input()) for i in range(B)]

X = [int(input()) for i in range(Q)]



INF = float('inf')

st = []

for s in S:

    i = bisect(T,s)

    x0,x1 = -INF,INF

    if i > 0: x0 = T[i-1]

    if i < B: x1 = T[i]

    st.append(min(s-x0, x1-s))

ts = []

for t in T:

    i = bisect(S,t)

    x0,x1 = -INF,INF

    if i > 0: x0 = S[i-1]

    if i < A: x1 = S[i]

    ts.append(min(t-x0, x1-t))



ans = []

for x in X:

    d0 = d1 = d2 = d3 = INF

    si = bisect(S,x)

    if si > 0:

        d0 = x-S[si-1] + st[si-1]

    if si < A:

        d1 = S[si]-x + st[si]

    ti = bisect(T,x)

    if ti > 0:

        d2 = x-T[ti-1] + ts[ti-1]

    if ti < B:

        d3 = T[ti]-x + ts[ti]

    ans.append(min(d0,d1,d2,d3))

print(*ans, sep='\n')

from bisect import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
qs = [int(input()) for i in range(Q)]
st = []
for s in S:
    ti = bisect(T, s)
    if ti == 0:
        st.append(abs(s - T[0]))
    elif ti == B:
        st.append(abs(s - T[-1]))
    else:
        tmp = min(abs(s - T[ti - 1]), abs(s - T[ti]))
        st.append(tmp)
ts = []
for t in T:
    si = bisect(S, t)
    if si == 0:
        ts.append(abs(t - S[0]))
    elif si == A:
        ts.append(abs(t - S[-1]))
    else:
        tmp = min(abs(t - S[si - 1]), abs(t - S[si]))
        ts.append(tmp)
ans = []
for q in qs:
    si = bisect(S, q)
    if si == 0:
        a = abs(q - S[0]) + st[0]
    elif si == A:
        a = abs(q - S[-1]) + st[-1]
    else:
        a = min(abs(q - S[si - 1]) + st[si - 1], abs(q - S[si]) + st[si])
    ti = bisect(T, q)
    if ti == 0:
        b = abs(q - T[0]) + ts[0]
    elif ti == B:
        b = abs(q - T[-1]) + ts[-1]
    else:
        b = min(abs(q - T[ti - 1]) + ts[ti - 1], abs(q - T[ti]) + ts[ti])
    ans.append(min(a, b))
print(*ans, sep="\n")

import sys

input = sys.stdin.readline
from bisect import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]
INF = float("inf")
st = []
for s in S:
    i = bisect(T, s)
    x0, x1 = -INF, INF
    if i > 0:
        x0 = T[i - 1]
    if i < B:
        x1 = T[i]
    st.append(min(s - x0, x1 - s))
ts = []
for t in T:
    i = bisect(S, t)
    x0, x1 = -INF, INF
    if i > 0:
        x0 = S[i - 1]
    if i < A:
        x1 = S[i]
    ts.append(min(t - x0, x1 - t))
ans = []
for x in X:
    d0 = d1 = d2 = d3 = INF
    si = bisect(S, x)
    if si > 0:
        d0 = x - S[si - 1] + st[si - 1]
    if si < A:
        d1 = S[si] - x + st[si]
    ti = bisect(T, x)
    if ti > 0:
        d2 = x - T[ti - 1] + ts[ti - 1]
    if ti < B:
        d3 = T[ti] - x + ts[ti]
    ans.append(min(d0, d1, d2, d3))
print(*ans, sep="\n")

+import sys + +input = sys.stdin.readline -qs = [int(input()) for i in range(Q)] +X = [int(input()) for i in range(Q)] +INF = float("inf") -    ti = bisect(T, s) -    if ti == 0: -        st.append(abs(s - T[0])) -    elif ti == B: -        st.append(abs(s - T[-1])) -    else: -        tmp = min(abs(s - T[ti - 1]), abs(s - T[ti])) -        st.append(tmp) +    i = bisect(T, s) +    x0, x1 = -INF, INF +    if i > 0: +        x0 = T[i - 1] +    if i < B: +        x1 = T[i] +    st.append(min(s - x0, x1 - s)) -    si = bisect(S, t) -    if si == 0: -        ts.append(abs(t - S[0])) -    elif si == A: -        ts.append(abs(t - S[-1])) -    else: -        tmp = min(abs(t - S[si - 1]), abs(t - S[si])) -        ts.append(tmp) +    i = bisect(S, t) +    x0, x1 = -INF, INF +    if i > 0: +        x0 = S[i - 1] +    if i < A: +        x1 = S[i] +    ts.append(min(t - x0, x1 - t)) -for q in qs: -    si = bisect(S, q) -    if si == 0: -        a = abs(q - S[0]) + st[0] -    elif si == A: -        a = abs(q - S[-1]) + st[-1] -    else: -        a = min(abs(q - S[si - 1]) + st[si - 1], abs(q - S[si]) + st[si]) -    ti = bisect(T, q) -    if ti == 0: -        b = abs(q - T[0]) + ts[0] -    elif ti == B: -        b = abs(q - T[-1]) + ts[-1] -    else: -        b = min(abs(q - T[ti - 1]) + ts[ti - 1], abs(q - T[ti]) + ts[ti]) -    ans.append(min(a, b)) +for x in X: +    d0 = d1 = d2 = d3 = INF +    si = bisect(S, x) +    if si > 0: +        d0 = x - S[si - 1] + st[si - 1] +    if si < A: +        d1 = S[si] - x + st[si] +    ti = bisect(T, x) +    if ti > 0: +        d2 = x - T[ti - 1] + ts[ti - 1] +    if ti < B: +        d3 = T[ti] - x + ts[ti] +    ans.append(min(d0, d1, d2, d3))