from bisect import bisect_left



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

s = [int(eval(input())) for _ in range(A)]

t = [int(eval(input())) for _ in range(B)]

x = [int(eval(input())) for _ in range(Q)]



for xx in x:

    # 神先

    ps_r = 0

    s_r = bisect_left(s, xx)

    if s_r < A:

        ps_r += s[s_r] - xx

        t_r = bisect_left(t, s[s_r])

        t_l = t_r - 1



        b = 0

        if t_r < B:

            b = t[t_r] - s[s_r]

        if 0 <= t_l < B:

            if b == 0:

                b = s[s_r] - t[t_l]

            else:

                b = min(b, s[s_r] - t[t_l])

        ps_r += b

    else:

        ps_r = 10 ** 12



    ps_l = 0

    s_l = s_r - 1

    if 0 <= s_l < A:

        ps_l += xx - s[s_l]

        t_r = bisect_left(t, s[s_l])

        t_l = t_r - 1



        b = 0

        if t_r < B:

            b = t[t_r] - s[s_l]

        if 0 <= t_l < B:

            if b == 0:

                b = s[s_l] - t[t_l]

            else:

                b = min(b, s[s_l] - t[t_l])

        ps_l += b

    else:

        ps_l = 10 ** 12



    # 寺前

    pt_r = 0

    t_r = bisect_left(t, xx)

    if t_r < B:

        pt_r += t[t_r] - xx

        s_r = bisect_left(s, t[t_r])

        s_l = s_r - 1



        b = 0

        if s_r < A:

            b = s[s_r] - t[t_r]

        if 0 <= s_l < A:

            if b == 0:

                b = t[t_r] - s[s_l]

            else:

                b = min(b, t[t_r] - s[s_l])

        pt_r += b

    else:

        pt_r = 10 ** 12



    pt_l = 0

    t_l = t_r - 1

    if 0 <= t_l < B:

        pt_l += xx - t[t_l]

        s_r = bisect_left(s, t[t_l])

        s_l = s_r - 1



        b = 0

        if s_r < A:

            b = s[s_r] - t[t_l]

        if 0 <= s_l < A:

            if b == 0:

                b = t[t_l] - s[s_l]

            else:

                b = min(b, t[t_l] - s[s_l])

        pt_l += b

    else:

        pt_l = 10 ** 12



    # print(ps_r, ps_l, pt_r, pt_l)

    print((min(ps_r, ps_l, pt_r, pt_l)))

from bisect import bisect_left

from itertools import product



inf = float('inf')



a, b, q = list(map(int, input().split()))

s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf]

t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf]

x = [int(eval(input())) for _ in range(q)]



for xx in x:

    ret = inf



    sr = bisect_left(s, xx)  # xx以上の最小値

    sl = max(0, sr - 1)



    tr = bisect_left(t, xx)

    tl = max(0, tr - 1)



    for ss, tt in product(s[sl:sr + 1], t[tl:tr + 1]):

        ret = min(

            ret,

            abs(xx - ss) + abs(ss - tt),

            abs(xx - tt) + abs(tt - ss)

        )

    print(ret)

from bisect import bisect_left

A, B, Q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(A)]
t = [int(eval(input())) for _ in range(B)]
x = [int(eval(input())) for _ in range(Q)]
for xx in x:
    # 神先
    ps_r = 0
    s_r = bisect_left(s, xx)
    if s_r < A:
        ps_r += s[s_r] - xx
        t_r = bisect_left(t, s[s_r])
        t_l = t_r - 1
        b = 0
        if t_r < B:
            b = t[t_r] - s[s_r]
        if 0 <= t_l < B:
            if b == 0:
                b = s[s_r] - t[t_l]
            else:
                b = min(b, s[s_r] - t[t_l])
        ps_r += b
    else:
        ps_r = 10**12
    ps_l = 0
    s_l = s_r - 1
    if 0 <= s_l < A:
        ps_l += xx - s[s_l]
        t_r = bisect_left(t, s[s_l])
        t_l = t_r - 1
        b = 0
        if t_r < B:
            b = t[t_r] - s[s_l]
        if 0 <= t_l < B:
            if b == 0:
                b = s[s_l] - t[t_l]
            else:
                b = min(b, s[s_l] - t[t_l])
        ps_l += b
    else:
        ps_l = 10**12
    # 寺前
    pt_r = 0
    t_r = bisect_left(t, xx)
    if t_r < B:
        pt_r += t[t_r] - xx
        s_r = bisect_left(s, t[t_r])
        s_l = s_r - 1
        b = 0
        if s_r < A:
            b = s[s_r] - t[t_r]
        if 0 <= s_l < A:
            if b == 0:
                b = t[t_r] - s[s_l]
            else:
                b = min(b, t[t_r] - s[s_l])
        pt_r += b
    else:
        pt_r = 10**12
    pt_l = 0
    t_l = t_r - 1
    if 0 <= t_l < B:
        pt_l += xx - t[t_l]
        s_r = bisect_left(s, t[t_l])
        s_l = s_r - 1
        b = 0
        if s_r < A:
            b = s[s_r] - t[t_l]
        if 0 <= s_l < A:
            if b == 0:
                b = t[t_l] - s[s_l]
            else:
                b = min(b, t[t_l] - s[s_l])
        pt_l += b
    else:
        pt_l = 10**12
    # print(ps_r, ps_l, pt_r, pt_l)
    print((min(ps_r, ps_l, pt_r, pt_l)))

from bisect import bisect_left
from itertools import product

inf = float("inf")
a, b, q = list(map(int, input().split()))
s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf]
t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf]
x = [int(eval(input())) for _ in range(q)]
for xx in x:
    ret = inf
    sr = bisect_left(s, xx)  # xx以上の最小値
    sl = max(0, sr - 1)
    tr = bisect_left(t, xx)
    tl = max(0, tr - 1)
    for ss, tt in product(s[sl : sr + 1], t[tl : tr + 1]):
        ret = min(ret, abs(xx - ss) + abs(ss - tt), abs(xx - tt) + abs(tt - ss))
    print(ret)

+from itertools import product -A, B, Q = list(map(int, input().split())) -s = [int(eval(input())) for _ in range(A)] -t = [int(eval(input())) for _ in range(B)] -x = [int(eval(input())) for _ in range(Q)] +inf = float("inf") +a, b, q = list(map(int, input().split())) +s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] +t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] +x = [int(eval(input())) for _ in range(q)] -    # 神先 -    ps_r = 0 -    s_r = bisect_left(s, xx) -    if s_r < A: -        ps_r += s[s_r] - xx -        t_r = bisect_left(t, s[s_r]) -        t_l = t_r - 1 -        b = 0 -        if t_r < B: -            b = t[t_r] - s[s_r] -        if 0 <= t_l < B: -            if b == 0: -                b = s[s_r] - t[t_l] -            else: -                b = min(b, s[s_r] - t[t_l]) -        ps_r += b -    else: -        ps_r = 10**12 -    ps_l = 0 -    s_l = s_r - 1 -    if 0 <= s_l < A: -        ps_l += xx - s[s_l] -        t_r = bisect_left(t, s[s_l]) -        t_l = t_r - 1 -        b = 0 -        if t_r < B: -            b = t[t_r] - s[s_l] -        if 0 <= t_l < B: -            if b == 0: -                b = s[s_l] - t[t_l] -            else: -                b = min(b, s[s_l] - t[t_l]) -        ps_l += b -    else: -        ps_l = 10**12 -    # 寺前 -    pt_r = 0 -    t_r = bisect_left(t, xx) -    if t_r < B: -        pt_r += t[t_r] - xx -        s_r = bisect_left(s, t[t_r]) -        s_l = s_r - 1 -        b = 0 -        if s_r < A: -            b = s[s_r] - t[t_r] -        if 0 <= s_l < A: -            if b == 0: -                b = t[t_r] - s[s_l] -            else: -                b = min(b, t[t_r] - s[s_l]) -        pt_r += b -    else: -        pt_r = 10**12 -    pt_l = 0 -    t_l = t_r - 1 -    if 0 <= t_l < B: -        pt_l += xx - t[t_l] -        s_r = bisect_left(s, t[t_l]) -        s_l = s_r - 1 -        b = 0 -        if s_r < A: -            b = s[s_r] - t[t_l] -        if 0 <= s_l < A: -            if b == 0: -                b = t[t_l] - s[s_l] -            else: -                b = min(b, t[t_l] - s[s_l]) -        pt_l += b -    else: -        pt_l = 10**12 -    # print(ps_r, ps_l, pt_r, pt_l) -    print((min(ps_r, ps_l, pt_r, pt_l))) +    ret = inf +    sr = bisect_left(s, xx)  # xx以上の最小値 +    sl = max(0, sr - 1) +    tr = bisect_left(t, xx) +    tl = max(0, tr - 1) +    for ss, tt in product(s[sl : sr + 1], t[tl : tr + 1]): +        ret = min(ret, abs(xx - ss) + abs(ss - tt), abs(xx - tt) + abs(tt - ss)) +    print(ret)