import sys

from bisect import bisect_left



def solve():

    input = sys.stdin.readline

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

    S = [int(eval(input())) for _ in range(A)]

    T = [int(eval(input())) for _ in range(B)]

    for _ in range(Q):

        x = int(eval(input()))

        si = bisect_left(S, x)

        ti = bisect_left(T, x)

        minLength = 10 **20

        both_left = 10 ** 20

        both_right = 10 ** 20

        s_t = 10 ** 20

        t_s = 10 ** 20

        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])

        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)

        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)

        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)

        minLength = min([both_left, both_right, s_t, t_s])

        print(minLength)



    return 0



if __name__ == "__main__":

    solve()
import sys

from bisect import bisect_left



def solve():

    input = sys.stdin.readline

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

    S = [int(eval(input())) for _ in range(A)]

    T = [int(eval(input())) for _ in range(B)]

    Ans = [0] * Q

    for i in range(Q):

        x = int(eval(input()))

        si, ti = bisect_left(S, x), bisect_left(T, x)

        shortest_path = 10 ** 20

        if si < A and ti < B: shortest_path = min(shortest_path, max(S[si], T[ti]) - x)

        if si > 0 and ti > 0: shortest_path = min(shortest_path, x - min(S[si-1], T[ti-1]))

        if si > 0 and ti < B: shortest_path = min(shortest_path, T[ti] - S[si-1] + min(T[ti] - x, x - S[si-1]))

        if ti > 0 and si < A: shortest_path = min(shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti-1]))

        Ans[i] = shortest_path

    print(("\n".join(map(str, Ans))))



    return 0



if __name__ == "__main__":

    solve()
import sys
from bisect import bisect_left


def solve():
    input = sys.stdin.readline
    A, B, Q = list(map(int, input().split()))
    S = [int(eval(input())) for _ in range(A)]
    T = [int(eval(input())) for _ in range(B)]
    for _ in range(Q):
        x = int(eval(input()))
        si = bisect_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10**20
        both_left = 10**20
        both_right = 10**20
        s_t = 10**20
        t_s = 10**20
        if si > 0 and ti > 0:
            both_left = max(x - S[si - 1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1:
            both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1:
            s_t = T[ti] - S[si - 1] + min(x - S[si - 1], T[ti] - x)
        if ti > 0 and si <= A - 1:
            t_s = S[si] - T[ti - 1] + min(x - T[ti - 1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)
    return 0


if __name__ == "__main__":
    solve()

import sys
from bisect import bisect_left


def solve():
    input = sys.stdin.readline
    A, B, Q = list(map(int, input().split()))
    S = [int(eval(input())) for _ in range(A)]
    T = [int(eval(input())) for _ in range(B)]
    Ans = [0] * Q
    for i in range(Q):
        x = int(eval(input()))
        si, ti = bisect_left(S, x), bisect_left(T, x)
        shortest_path = 10**20
        if si < A and ti < B:
            shortest_path = min(shortest_path, max(S[si], T[ti]) - x)
        if si > 0 and ti > 0:
            shortest_path = min(shortest_path, x - min(S[si - 1], T[ti - 1]))
        if si > 0 and ti < B:
            shortest_path = min(
                shortest_path, T[ti] - S[si - 1] + min(T[ti] - x, x - S[si - 1])
            )
        if ti > 0 and si < A:
            shortest_path = min(
                shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti - 1])
            )
        Ans[i] = shortest_path
    print(("\n".join(map(str, Ans))))
    return 0


if __name__ == "__main__":
    solve()

-    for _ in range(Q): +    Ans = [0] * Q +    for i in range(Q): -        si = bisect_left(S, x) -        ti = bisect_left(T, x) -        minLength = 10**20 -        both_left = 10**20 -        both_right = 10**20 -        s_t = 10**20 -        t_s = 10**20 +        si, ti = bisect_left(S, x), bisect_left(T, x) +        shortest_path = 10**20 +        if si < A and ti < B: +            shortest_path = min(shortest_path, max(S[si], T[ti]) - x) -            both_left = max(x - S[si - 1], x - T[ti - 1]) -        if si <= A - 1 and ti <= B - 1: -            both_right = max(S[si] - x, T[ti] - x) -        if si > 0 and ti <= B - 1: -            s_t = T[ti] - S[si - 1] + min(x - S[si - 1], T[ti] - x) -        if ti > 0 and si <= A - 1: -            t_s = S[si] - T[ti - 1] + min(x - T[ti - 1], S[si] - x) -        minLength = min([both_left, both_right, s_t, t_s]) -        print(minLength) +            shortest_path = min(shortest_path, x - min(S[si - 1], T[ti - 1])) +        if si > 0 and ti < B: +            shortest_path = min( +                shortest_path, T[ti] - S[si - 1] + min(T[ti] - x, x - S[si - 1]) +            ) +        if ti > 0 and si < A: +            shortest_path = min( +                shortest_path, S[si] - T[ti - 1] + min(S[si] - x, x - T[ti - 1]) +            ) +        Ans[i] = shortest_path +    print(("\n".join(map(str, Ans))))