from bisect import bisect_left
a, b, q = map(int, input().split())
s = []
for _ in range(a):
    s.append(int(input()))
t = []
for _ in range(b):
    t.append(int(input()))
INF = 10**12
for _ in range(q):
    x = int(input())
    s_l = t_l = -INF
    s_r = t_r = INF
    tmp = bisect_left(s, x)
    if tmp>0:
        s_l = s[tmp-1]
    if tmp<a:
        s_r = s[tmp]
    tmp = bisect_left(t, x)
    if tmp>0:
        t_l = t[tmp-1]
    if tmp<b:
        t_r = t[tmp]
    ans = min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    )
    print(ans) from bisect import bisect_left a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q s = [] s [] for _ in range(a):
    s.append(int(input())) _ range(a) range a s.append(int(input())) s.append s append int(input()) int input() input t = [] t [] for _ in range(b):
    t.append(int(input())) _ range(b) range b t.append(int(input())) t.append t append int(input()) int input() input INF = 10**12 INF 10**12 10 12 for _ in range(q):
    x = int(input())
    s_l = t_l = -INF
    s_r = t_r = INF
    tmp = bisect_left(s, x)
    if tmp>0:
        s_l = s[tmp-1]
    if tmp<a:
        s_r = s[tmp]
    tmp = bisect_left(t, x)
    if tmp>0:
        t_l = t[tmp-1]
    if tmp<b:
        t_r = t[tmp]
    ans = min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    )
    print(ans) _ range(q) range q x = int(input()) x int(input()) int input() input s_l = t_l = -INF s_l -INF INF = t_l = -INF t_l -INF s_r = t_r = INF s_r INF = t_r = INF t_r INF tmp = bisect_left(s, x) tmp bisect_left(s, x) bisect_left s x if tmp>0:
        s_l = s[tmp-1]
     tmp>0 tmp 0 s_l = s[tmp-1] s_l s[tmp-1] s tmp-1 tmp 1 if tmp<a:
        s_r = s[tmp]
     tmp<a tmp a s_r = s[tmp] s_r s[tmp] s tmp tmp = bisect_left(t, x) tmp bisect_left(t, x) bisect_left t x if tmp>0:
        t_l = t[tmp-1]
     tmp>0 tmp 0 t_l = t[tmp-1] t_l t[tmp-1] t tmp-1 tmp 1 if tmp<b:
        t_r = t[tmp]
     tmp<b tmp b t_r = t[tmp] t_r t[tmp] t tmp ans = min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    ) ans min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    ) min x-min(s_l, t_l) x min(s_l, t_l) min s_l t_l max(s_r, t_r)-x max(s_r, t_r) max s_r t_r x s_r-t_l+min(s_r-x, x-t_l) s_r-t_l s_r t_l min(s_r-x, x-t_l) min s_r-x s_r x x-t_l x t_l t_r-s_l+min(t_r-x, x-s_l) t_r-s_l t_r s_l min(t_r-x, x-s_l) min t_r-x t_r x x-s_l x s_l print(ans) print ans t = [] [] t INF = 10**12 10**12 INF ans = min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    ) min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    ) ans b, q = map(int, input().split()) map(int, input().split()) b t_r = INF INF t_r t_r = t[tmp] t[tmp] t_r s_r = s[tmp] s[tmp] s_r t_l = t[tmp-1] t[tmp-1] t_l q = map(int, input().split()) map(int, input().split()) q s_l = t_l = -INF -INF s_l s_r = t_r = INF INF s_r s_l = s[tmp-1] s[tmp-1] s_l s = [] [] s x = int(input()) int(input()) x tmp = bisect_left(s, x) bisect_left(s, x) tmp t_l = -INF -INF t_l tmp = bisect_left(t, x) bisect_left(t, x) tmp a, b, q = map(int, input().split()) map(int, input().split()) a
from bisect import bisect_left
a, b, q = map(int, input().split())
s = []
for _ in range(a):
    s.append(int(input()))
t = []
for _ in range(b):
    t.append(int(input()))
INF = 10**12
for _ in range(q):
    x = int(input())
    s_l = t_l = -INF
    s_r = t_r = INF
    tmp = bisect_left(s, x)
    if tmp>0:
        s_l = s[tmp-1]
    if tmp<a:
        s_r = s[tmp]
    tmp = bisect_left(t, x)
    if tmp>0:
        t_l = t[tmp-1]
    if tmp<b:
        t_r = t[tmp]
    ans = min(
        x-min(s_l, t_l),
        max(s_r, t_r)-x,
        s_r-t_l+min(s_r-x, x-t_l),
        t_r-s_l+min(t_r-x, x-s_l)
    )
    print(ans)