from bisect import bisect



num_a,num_b,num_q = list(map(int, input().split(' ')))



lsa = [int(eval(input())) for _ in range(num_a)]

lsb = [int(eval(input())) for _ in range(num_b)]

lsa.sort()

lsb.sort()

# print(lsa)

# print(lsb)

lsq = [int(eval(input())) for _ in range(num_q)]



for ques in lsq:

    lower_bound_a = bisect(lsa, ques)

    lower_bound_b = bisect(lsb, ques)

    upper_bound_a = lower_bound_a - 1

    upper_bound_b = lower_bound_b - 1



    min_cand = 9223372036854775807

    if lower_bound_a < num_a and lower_bound_b < num_b:

        min_cand = min(min_cand, max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques)

    if upper_bound_a >= 0 and upper_bound_b >= 0:

        min_cand = min(min_cand, ques - min(lsa[upper_bound_a], lsb[upper_bound_b]))

    if upper_bound_a >= 0 and lower_bound_b < num_b:

        min_cand = min(

            min_cand, 

            lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],

            ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],

        )

    if lower_bound_a < num_a and upper_bound_b >= 0:

        min_cand = min(

            min_cand, 

            lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],

            ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],

        )

    

    print(min_cand)

from bisect import bisect

LONG_MIN = -9223372036854775808

LONG_MAX = 9223372036854775807



num_a,num_b,num_q = list(map(int, input().split(' ')))

lsa = [int(eval(input())) for _ in range(num_a)] + [LONG_MIN, LONG_MAX]

lsb = [int(eval(input())) for _ in range(num_b)] + [LONG_MIN, LONG_MAX]

lsa.sort()

lsb.sort()

lsq = [int(eval(input())) for _ in range(num_q)]



for ques in lsq:

    lower_bound_a = bisect(lsa, ques)

    lower_bound_b = bisect(lsb, ques)

    upper_bound_a = lower_bound_a - 1

    upper_bound_b = lower_bound_b - 1



    res = min(

        max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques, 

        ques - min(lsa[upper_bound_a], lsb[upper_bound_b]),

        lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],

        ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],

        lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],

        ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],

    )

    

    print(res)

from bisect import bisect

num_a, num_b, num_q = list(map(int, input().split(" ")))
lsa = [int(eval(input())) for _ in range(num_a)]
lsb = [int(eval(input())) for _ in range(num_b)]
lsa.sort()
lsb.sort()
# print(lsa)
# print(lsb)
lsq = [int(eval(input())) for _ in range(num_q)]
for ques in lsq:
    lower_bound_a = bisect(lsa, ques)
    lower_bound_b = bisect(lsb, ques)
    upper_bound_a = lower_bound_a - 1
    upper_bound_b = lower_bound_b - 1
    min_cand = 9223372036854775807
    if lower_bound_a < num_a and lower_bound_b < num_b:
        min_cand = min(min_cand, max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques)
    if upper_bound_a >= 0 and upper_bound_b >= 0:
        min_cand = min(min_cand, ques - min(lsa[upper_bound_a], lsb[upper_bound_b]))
    if upper_bound_a >= 0 and lower_bound_b < num_b:
        min_cand = min(
            min_cand,
            lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],
            ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],
        )
    if lower_bound_a < num_a and upper_bound_b >= 0:
        min_cand = min(
            min_cand,
            lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],
            ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],
        )
    print(min_cand)

from bisect import bisect

LONG_MIN = -9223372036854775808
LONG_MAX = 9223372036854775807
num_a, num_b, num_q = list(map(int, input().split(" ")))
lsa = [int(eval(input())) for _ in range(num_a)] + [LONG_MIN, LONG_MAX]
lsb = [int(eval(input())) for _ in range(num_b)] + [LONG_MIN, LONG_MAX]
lsa.sort()
lsb.sort()
lsq = [int(eval(input())) for _ in range(num_q)]
for ques in lsq:
    lower_bound_a = bisect(lsa, ques)
    lower_bound_b = bisect(lsb, ques)
    upper_bound_a = lower_bound_a - 1
    upper_bound_b = lower_bound_b - 1
    res = min(
        max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques,
        ques - min(lsa[upper_bound_a], lsb[upper_bound_b]),
        lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],
        ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],
        lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],
        ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],
    )
    print(res)

+LONG_MIN = -9223372036854775808 +LONG_MAX = 9223372036854775807 -lsa = [int(eval(input())) for _ in range(num_a)] -lsb = [int(eval(input())) for _ in range(num_b)] +lsa = [int(eval(input())) for _ in range(num_a)] + [LONG_MIN, LONG_MAX] +lsb = [int(eval(input())) for _ in range(num_b)] + [LONG_MIN, LONG_MAX] -# print(lsa) -# print(lsb) -    min_cand = 9223372036854775807 -    if lower_bound_a < num_a and lower_bound_b < num_b: -        min_cand = min(min_cand, max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques) -    if upper_bound_a >= 0 and upper_bound_b >= 0: -        min_cand = min(min_cand, ques - min(lsa[upper_bound_a], lsb[upper_bound_b])) -    if upper_bound_a >= 0 and lower_bound_b < num_b: -        min_cand = min( -            min_cand, -            lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a], -            ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a], -        ) -    if lower_bound_a < num_a and upper_bound_b >= 0: -        min_cand = min( -            min_cand, -            lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b], -            ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b], -        ) -    print(min_cand) +    res = min( +        max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques, +        ques - min(lsa[upper_bound_a], lsb[upper_bound_b]), +        lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a], +        ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a], +        lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b], +        ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b], +    ) +    print(res)