import bisect

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

S = [-float("inf")] + sorted([int(eval(input())) for k in range(A)]) + [float("inf")]

T = [-float("inf")] + sorted([int(eval(input())) for k in range(B)]) + [float("inf")]

X = [int(eval(input())) for k in range(Q)]



for x in X:

    p = bisect.bisect_left(S,x)

    q = bisect.bisect_left(T,x)

    t1 = max(abs(S[p]-x),abs(T[q]-x))

    t2 = max(abs(S[p-1]-x),abs(T[q-1]-x))

    t3 = abs(S[p-1]-x)+abs(S[p-1]-T[q])

    t4 = abs(T[q-1]-x)+abs(S[p]-T[q-1])    

    t5 = abs(S[p]-x)+abs(S[p]-T[q-1])    

    t6 = abs(T[q]-x)+abs(S[p-1]-T[q])

    print((min(t1,t2,t3,t4,t5,t6)))
import sys, math, bisect

sys.setrecursionlimit(200010)



def input():

    return sys.stdin.readline()[:-1]



def main():

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

    s = [-10**12] + sorted([int(eval(input())) for k in range(A)]) + [10**12]

    t = [-10**12] + sorted([int(eval(input())) for k in range(B)]) + [10**12]

    for _ in range(Q):

        q = int(eval(input()))

        s1 = s[bisect.bisect_left(s,q)]

        s2 = s[bisect.bisect_left(s,q)-1]

        t1 = t[bisect.bisect_left(t,q)]

        t2 = t[bisect.bisect_left(t,q)-1]

        d1 = max(q-s2,q-t2)

        d2 = max(s1-q,t1-q)

        d3 = 2*(q-s2)+t1-q

        d4 = 2*(q-t2)+s1-q

        d5 = 2*(s1-q)+q-t2

        d6 = 2*(t1-q)+q-s2

        print((min(d1,d2,d3,d4,d5,d6)))



if __name__ == '__main__':

    main()

import bisect

A, B, Q = list(map(int, input().split()))
S = [-float("inf")] + sorted([int(eval(input())) for k in range(A)]) + [float("inf")]
T = [-float("inf")] + sorted([int(eval(input())) for k in range(B)]) + [float("inf")]
X = [int(eval(input())) for k in range(Q)]
for x in X:
    p = bisect.bisect_left(S, x)
    q = bisect.bisect_left(T, x)
    t1 = max(abs(S[p] - x), abs(T[q] - x))
    t2 = max(abs(S[p - 1] - x), abs(T[q - 1] - x))
    t3 = abs(S[p - 1] - x) + abs(S[p - 1] - T[q])
    t4 = abs(T[q - 1] - x) + abs(S[p] - T[q - 1])
    t5 = abs(S[p] - x) + abs(S[p] - T[q - 1])
    t6 = abs(T[q] - x) + abs(S[p - 1] - T[q])
    print((min(t1, t2, t3, t4, t5, t6)))

import sys, math, bisect

sys.setrecursionlimit(200010)


def input():
    return sys.stdin.readline()[:-1]


def main():
    A, B, Q = list(map(int, input().split()))
    s = [-(10**12)] + sorted([int(eval(input())) for k in range(A)]) + [10**12]
    t = [-(10**12)] + sorted([int(eval(input())) for k in range(B)]) + [10**12]
    for _ in range(Q):
        q = int(eval(input()))
        s1 = s[bisect.bisect_left(s, q)]
        s2 = s[bisect.bisect_left(s, q) - 1]
        t1 = t[bisect.bisect_left(t, q)]
        t2 = t[bisect.bisect_left(t, q) - 1]
        d1 = max(q - s2, q - t2)
        d2 = max(s1 - q, t1 - q)
        d3 = 2 * (q - s2) + t1 - q
        d4 = 2 * (q - t2) + s1 - q
        d5 = 2 * (s1 - q) + q - t2
        d6 = 2 * (t1 - q) + q - s2
        print((min(d1, d2, d3, d4, d5, d6)))


if __name__ == "__main__":
    main()

-import bisect +import sys, math, bisect -A, B, Q = list(map(int, input().split())) -S = [-float("inf")] + sorted([int(eval(input())) for k in range(A)]) + [float("inf")] -T = [-float("inf")] + sorted([int(eval(input())) for k in range(B)]) + [float("inf")] -X = [int(eval(input())) for k in range(Q)] -for x in X: -    p = bisect.bisect_left(S, x) -    q = bisect.bisect_left(T, x) -    t1 = max(abs(S[p] - x), abs(T[q] - x)) -    t2 = max(abs(S[p - 1] - x), abs(T[q - 1] - x)) -    t3 = abs(S[p - 1] - x) + abs(S[p - 1] - T[q]) -    t4 = abs(T[q - 1] - x) + abs(S[p] - T[q - 1]) -    t5 = abs(S[p] - x) + abs(S[p] - T[q - 1]) -    t6 = abs(T[q] - x) + abs(S[p - 1] - T[q]) -    print((min(t1, t2, t3, t4, t5, t6))) +sys.setrecursionlimit(200010) + + +def input(): +    return sys.stdin.readline()[:-1] + + +def main(): +    A, B, Q = list(map(int, input().split())) +    s = [-(10**12)] + sorted([int(eval(input())) for k in range(A)]) + [10**12] +    t = [-(10**12)] + sorted([int(eval(input())) for k in range(B)]) + [10**12] +    for _ in range(Q): +        q = int(eval(input())) +        s1 = s[bisect.bisect_left(s, q)] +        s2 = s[bisect.bisect_left(s, q) - 1] +        t1 = t[bisect.bisect_left(t, q)] +        t2 = t[bisect.bisect_left(t, q) - 1] +        d1 = max(q - s2, q - t2) +        d2 = max(s1 - q, t1 - q) +        d3 = 2 * (q - s2) + t1 - q +        d4 = 2 * (q - t2) + s1 - q +        d5 = 2 * (s1 - q) + q - t2 +        d6 = 2 * (t1 - q) + q - s2 +        print((min(d1, d2, d3, d4, d5, d6))) + + +if __name__ == "__main__": +    main()