def search(x, l, first, end):

    if end-first<=1:

        if x<l[first]:

            return -1

        elif x>l[end]:

            return end

        else:

            return first

    middle = (first+end)//2

    if x >= l[middle]:

        return search(x, l, middle, end)

    else:

        return search(x, l, first, middle)

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

INF = 10**18

s = [-INF]+[int(eval(input())) for i in range(A)]+[INF]

t = [-INF]+[int(eval(input())) for i in range(B)]+[INF]

s.sort()

t.sort()

answer = []

for i in range(Q):

    x = int(eval(input()))

    sk = search(x,s,0,A)

    tk = search(x,t,0,B)

    ptn1 = abs(s[sk]-x) + min(abs(t[tk]-s[sk]),abs(t[tk+1]-s[sk]))

    ptn2 = abs(s[sk+1]-x) + min(abs(t[tk]-s[sk+1]),abs(t[tk+1]-s[sk+1]))

    ptn3 = abs(t[tk]-x) + min(abs(s[sk]-t[tk]),abs(s[sk+1]-t[tk]))

    ptn4 = abs(t[tk+1]-x) + min(abs(s[sk]-t[tk+1]),abs(s[sk+1]-t[tk+1]))

    answer.append(min(ptn1,ptn2,ptn3,ptn4))

for i in answer:

    print(i)
import bisect

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

INF = 10**18

s = [-INF]+[int(eval(input())) for i in range(A)]+[INF]

t = [-INF]+[int(eval(input())) for i in range(B)]+[INF]

s.sort()

t.sort()

answer = []

for i in range(Q):

    x = int(eval(input()))

    sk = bisect.bisect_left(s,x)-1

    tk = bisect.bisect_left(t,x)-1

    ptn1 = abs(s[sk]-x) + min(abs(t[tk]-s[sk]),abs(t[tk+1]-s[sk]))

    ptn2 = abs(s[sk+1]-x) + min(abs(t[tk]-s[sk+1]),abs(t[tk+1]-s[sk+1]))

    ptn3 = abs(t[tk]-x) + min(abs(s[sk]-t[tk]),abs(s[sk+1]-t[tk]))

    ptn4 = abs(t[tk+1]-x) + min(abs(s[sk]-t[tk+1]),abs(s[sk+1]-t[tk+1]))

    answer.append(min(ptn1,ptn2,ptn3,ptn4))

for i in answer:

    print(i)

def search(x, l, first, end):
    if end - first <= 1:
        if x < l[first]:
            return -1
        elif x > l[end]:
            return end
        else:
            return first
    middle = (first + end) // 2
    if x >= l[middle]:
        return search(x, l, middle, end)
    else:
        return search(x, l, first, middle)


A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
s.sort()
t.sort()
answer = []
for i in range(Q):
    x = int(eval(input()))
    sk = search(x, s, 0, A)
    tk = search(x, t, 0, B)
    ptn1 = abs(s[sk] - x) + min(abs(t[tk] - s[sk]), abs(t[tk + 1] - s[sk]))
    ptn2 = abs(s[sk + 1] - x) + min(abs(t[tk] - s[sk + 1]), abs(t[tk + 1] - s[sk + 1]))
    ptn3 = abs(t[tk] - x) + min(abs(s[sk] - t[tk]), abs(s[sk + 1] - t[tk]))
    ptn4 = abs(t[tk + 1] - x) + min(abs(s[sk] - t[tk + 1]), abs(s[sk + 1] - t[tk + 1]))
    answer.append(min(ptn1, ptn2, ptn3, ptn4))
for i in answer:
    print(i)

import bisect

A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
s.sort()
t.sort()
answer = []
for i in range(Q):
    x = int(eval(input()))
    sk = bisect.bisect_left(s, x) - 1
    tk = bisect.bisect_left(t, x) - 1
    ptn1 = abs(s[sk] - x) + min(abs(t[tk] - s[sk]), abs(t[tk + 1] - s[sk]))
    ptn2 = abs(s[sk + 1] - x) + min(abs(t[tk] - s[sk + 1]), abs(t[tk + 1] - s[sk + 1]))
    ptn3 = abs(t[tk] - x) + min(abs(s[sk] - t[tk]), abs(s[sk + 1] - t[tk]))
    ptn4 = abs(t[tk + 1] - x) + min(abs(s[sk] - t[tk + 1]), abs(s[sk + 1] - t[tk + 1]))
    answer.append(min(ptn1, ptn2, ptn3, ptn4))
for i in answer:
    print(i)

-def search(x, l, first, end): -    if end - first <= 1: -        if x < l[first]: -            return -1 -        elif x > l[end]: -            return end -        else: -            return first -    middle = (first + end) // 2 -    if x >= l[middle]: -        return search(x, l, middle, end) -    else: -        return search(x, l, first, middle) - +import bisect -    sk = search(x, s, 0, A) -    tk = search(x, t, 0, B) +    sk = bisect.bisect_left(s, x) - 1 +    tk = bisect.bisect_left(t, x) - 1