import bisect

import sys



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

s = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18])

t = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18])





def solve(s,t,x):

    ans = 10**18

    for i in range(2):

        a, b = (s, t) if i==0 else (t, s)

        posX1 = bisect.bisect_left(a,x)

        for j in range(2):

            ax = a[posX1 -j]

            posX2 = bisect.bisect_left(b,ax)

            for k in range(2):

                bx = b[posX2-k]

                ans = min(ans, abs(x-ax)+abs(bx-ax))

    return ans



for _ in range(Q):

    x = int(eval(input()))

    print((solve(s,t,x)))
import bisect

import sys



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

s = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18])

t = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18])





def solve(s,t,x):

    ans = 10**18

    for i in range(2):

        a, b = (s, t) if i==0 else (t, s)

        posX1 = bisect.bisect_left(a,x)

        for j in range(2):

            ax = a[posX1 -j]

            posX2 = bisect.bisect_left(b,ax)

            for k in range(2):

                bx = b[posX2-k]

                ans = min(ans, abs(x-ax)+abs(bx-ax))

    return ans



ans = [solve(s,t,x) for x in map(int,sys.stdin)]

print(*ans, sep="\n")

import bisect
import sys

A, B, Q = list(map(int, input().split()))
s = tuple(
    [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0] * A))) + [10**18]
)
t = tuple(
    [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0] * B))) + [10**18]
)


def solve(s, t, x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i == 0 else (t, s)
        posX1 = bisect.bisect_left(a, x)
        for j in range(2):
            ax = a[posX1 - j]
            posX2 = bisect.bisect_left(b, ax)
            for k in range(2):
                bx = b[posX2 - k]
                ans = min(ans, abs(x - ax) + abs(bx - ax))
    return ans


for _ in range(Q):
    x = int(eval(input()))
    print((solve(s, t, x)))

import bisect
import sys

A, B, Q = map(int, input().split())
s = tuple(
    [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0] * A))) + [10**18]
)
t = tuple(
    [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0] * B))) + [10**18]
)


def solve(s, t, x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i == 0 else (t, s)
        posX1 = bisect.bisect_left(a, x)
        for j in range(2):
            ax = a[posX1 - j]
            posX2 = bisect.bisect_left(b, ax)
            for k in range(2):
                bx = b[posX2 - k]
                ans = min(ans, abs(x - ax) + abs(bx - ax))
    return ans


ans = [solve(s, t, x) for x in map(int, sys.stdin)]
print(*ans, sep="\n")

-A, B, Q = list(map(int, input().split())) +A, B, Q = map(int, input().split()) -for _ in range(Q): -    x = int(eval(input())) -    print((solve(s, t, x))) +ans = [solve(s, t, x) for x in map(int, sys.stdin)] +print(*ans, sep="\n")