import sys

def main():

    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)]

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

    from bisect import bisect_left

    INF=10**11

    S=[-INF] + S + [INF]

    T=[-INF] + T + [INF]

    for x in X:

        sr = bisect_left(S, x)

        tr = bisect_left(T, x)

        sl,tl=sr-1,tr-1

        ans=INF

        ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x)))

        ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x)))

        ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x)))

        ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x)))

        print(ans)



if __name__ == '__main__':

    main()
from bisect import bisect_left

import sys

def main():

    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)]

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

    INF = 10 ** 11

    S = [-INF] + S + [INF]

    T = [-INF] + T + [INF]

    for x in X:

        i = bisect_left(S, x)

        ls = x - S[i - 1]

        rs = S[i] - x

        j = bisect_left(T, x)

        lt = x - T[j - 1]

        rt = T[j] - x

        print((min(max(ls, lt), max(rs, rt), 2 * ls + rt, ls + 2 * rt, 2 * rs + lt, rs + 2 * lt)))



if __name__ == '__main__':

    main()

import sys


def main():
    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)]
    X = [int(eval(input())) for _ in range(Q)]
    from bisect import bisect_left

    INF = 10**11
    S = [-INF] + S + [INF]
    T = [-INF] + T + [INF]
    for x in X:
        sr = bisect_left(S, x)
        tr = bisect_left(T, x)
        sl, tl = sr - 1, tr - 1
        ans = INF
        ans = min(ans, abs(S[sl] - T[tl]) + min(abs(S[sl] - x), abs(T[tl] - x)))
        ans = min(ans, abs(S[sl] - T[tr]) + min(abs(S[sl] - x), abs(T[tr] - x)))
        ans = min(ans, abs(S[sr] - T[tl]) + min(abs(S[sr] - x), abs(T[tl] - x)))
        ans = min(ans, abs(S[sr] - T[tr]) + min(abs(S[sr] - x), abs(T[tr] - x)))
        print(ans)


if __name__ == "__main__":
    main()

from bisect import bisect_left
import sys


def main():
    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)]
    X = [int(eval(input())) for _ in range(Q)]
    INF = 10**11
    S = [-INF] + S + [INF]
    T = [-INF] + T + [INF]
    for x in X:
        i = bisect_left(S, x)
        ls = x - S[i - 1]
        rs = S[i] - x
        j = bisect_left(T, x)
        lt = x - T[j - 1]
        rt = T[j] - x
        print(
            (
                min(
                    max(ls, lt),
                    max(rs, rt),
                    2 * ls + rt,
                    ls + 2 * rt,
                    2 * rs + lt,
                    rs + 2 * lt,
                )
            )
        )


if __name__ == "__main__":
    main()

+from bisect import bisect_left -    from bisect import bisect_left - -        sr = bisect_left(S, x) -        tr = bisect_left(T, x) -        sl, tl = sr - 1, tr - 1 -        ans = INF -        ans = min(ans, abs(S[sl] - T[tl]) + min(abs(S[sl] - x), abs(T[tl] - x))) -        ans = min(ans, abs(S[sl] - T[tr]) + min(abs(S[sl] - x), abs(T[tr] - x))) -        ans = min(ans, abs(S[sr] - T[tl]) + min(abs(S[sr] - x), abs(T[tl] - x))) -        ans = min(ans, abs(S[sr] - T[tr]) + min(abs(S[sr] - x), abs(T[tr] - x))) -        print(ans) +        i = bisect_left(S, x) +        ls = x - S[i - 1] +        rs = S[i] - x +        j = bisect_left(T, x) +        lt = x - T[j - 1] +        rt = T[j] - x +        print( +            ( +                min( +                    max(ls, lt), +                    max(rs, rt), +                    2 * ls + rt, +                    ls + 2 * rt, +                    2 * rs + lt, +                    rs + 2 * lt, +                ) +            ) +        )