def near(x, Y):

    i = bisect_left(Y,x)

    if i == 0:

        return Y[i]-x

    elif i == len(Y):

        return x-Y[i-1]

    else:

        return min(Y[i]-x, x-Y[i-1])



def near2(x, Y):

    i = bisect_left(Y,x)

    if i == 0:

        return Y[i]-x + D[i][1]

    elif i == len(Y):

        return x-Y[i-1] + D[i-1][1]

    else:

        return min(Y[i]-x+D[i][1], x-Y[i-1]+D[i-1][1])



from bisect import *

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

S = []

T = []

for _ in range(A):

    S.append(int(eval(input())))

for _ in range(B):

    T.append(int(eval(input())))

D = []

for a in S:

    D.append((a, near(a, T)))

for b in T:

    D.append((b, near(b, S)))

D.sort(key=lambda x:x[0])

D2 = [d for d, _ in D]

for _ in range(Q):

    x = int(eval(input()))

    print((near2(x,D2)))



def near(x, X):

    i = bisect_left(X, x)

    if i == 0: return [X[i]-x]

    elif i == len(X): return [X[i-1]-x]

    else: return [X[i]-x, X[i-1]-x]

from bisect import *

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

S, T = [], []

for _ in range(A):

    S.append(int(eval(input())))

for _ in range(B):

    T.append(int(eval(input())))

for _ in range(Q):

    res = 1<<40

    x = int(eval(input()))

    for a in near(x,S):

        for b in near(x,T):

            res = min(abs(a)+abs(a-b), abs(b)+abs(b-a), res)

    print(res)
def near(x, Y):
    i = bisect_left(Y, x)
    if i == 0:
        return Y[i] - x
    elif i == len(Y):
        return x - Y[i - 1]
    else:
        return min(Y[i] - x, x - Y[i - 1])


def near2(x, Y):
    i = bisect_left(Y, x)
    if i == 0:
        return Y[i] - x + D[i][1]
    elif i == len(Y):
        return x - Y[i - 1] + D[i - 1][1]
    else:
        return min(Y[i] - x + D[i][1], x - Y[i - 1] + D[i - 1][1])


from bisect import *

A, B, Q = list(map(int, input().split()))
S = []
T = []
for _ in range(A):
    S.append(int(eval(input())))
for _ in range(B):
    T.append(int(eval(input())))
D = []
for a in S:
    D.append((a, near(a, T)))
for b in T:
    D.append((b, near(b, S)))
D.sort(key=lambda x: x[0])
D2 = [d for d, _ in D]
for _ in range(Q):
    x = int(eval(input()))
    print((near2(x, D2)))

def near(x, X):
    i = bisect_left(X, x)
    if i == 0:
        return [X[i] - x]
    elif i == len(X):
        return [X[i - 1] - x]
    else:
        return [X[i] - x, X[i - 1] - x]


from bisect import *

A, B, Q = list(map(int, input().split()))
S, T = [], []
for _ in range(A):
    S.append(int(eval(input())))
for _ in range(B):
    T.append(int(eval(input())))
for _ in range(Q):
    res = 1 << 40
    x = int(eval(input()))
    for a in near(x, S):
        for b in near(x, T):
            res = min(abs(a) + abs(a - b), abs(b) + abs(b - a), res)
    print(res)

-def near(x, Y): -    i = bisect_left(Y, x) +def near(x, X): +    i = bisect_left(X, x) -        return Y[i] - x -    elif i == len(Y): -        return x - Y[i - 1] +        return [X[i] - x] +    elif i == len(X): +        return [X[i - 1] - x] -        return min(Y[i] - x, x - Y[i - 1]) - - -def near2(x, Y): -    i = bisect_left(Y, x) -    if i == 0: -        return Y[i] - x + D[i][1] -    elif i == len(Y): -        return x - Y[i - 1] + D[i - 1][1] -    else: -        return min(Y[i] - x + D[i][1], x - Y[i - 1] + D[i - 1][1]) +        return [X[i] - x, X[i - 1] - x] -S = [] -T = [] +S, T = [], [] -D = [] -for a in S: -    D.append((a, near(a, T))) -for b in T: -    D.append((b, near(b, S))) -D.sort(key=lambda x: x[0]) -D2 = [d for d, _ in D] +    res = 1 << 40 -    print((near2(x, D2))) +    for a in near(x, S): +        for b in near(x, T): +            res = min(abs(a) + abs(a - b), abs(b) + abs(b - a), res) +    print(res)