import bisect

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

INF = 10 ** 18

s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]

t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]

for q in range(Q):

    x = int(eval(input()))

    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)

    res = INF

    for S in [s[b - 1], s[b]]:

        for T in [t[d - 1], t[d]]:

            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)

            res = min(res, d1, d2)

    print(res)
from bisect import bisect_left





def solve(string):

    a, b, q, *stx = list(map(int, string.split()))

    s = [-10**10] + stx[:a] + [2 * 10**10]

    t = [-10**10] + stx[a:a + b] + [2 * 10**10]

    x = dict([])

    i_s = 0

    i_t = 0

    for _x in sorted(set(stx[-q:])):

        """

        while s[i_s] < _x:

            i_s += 1

        while t[i_t] < _x:

            i_t += 1

        """

        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)

        ls, rs = s[i_s - 1], s[i_s]

        lt, rt = t[i_t - 1], t[i_t]

        r_max = max(rs, rt)

        l_min = min(ls, lt)

        x[_x] = min([

            r_max - _x, _x - l_min, rt - ls + min(rt - _x, _x - ls),

            rs - lt + min(rs - _x, _x - lt)

        ])

    return "\n".join([str(x[_x]) for _x in stx[-q:]])





if __name__ == '__main__':

    n, m, l = list(map(int, input().split()))

    print((solve('{} {} {}\n'.format(n, m, l) + '\n'.join([eval(input()) for _ in range(n + m + l)]))))

import bisect

A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
    x = int(eval(input()))
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

from bisect import bisect_left


def solve(string):
    a, b, q, *stx = list(map(int, string.split()))
    s = [-(10**10)] + stx[:a] + [2 * 10**10]
    t = [-(10**10)] + stx[a : a + b] + [2 * 10**10]
    x = dict([])
    i_s = 0
    i_t = 0
    for _x in sorted(set(stx[-q:])):
        """
        while s[i_s] < _x:
            i_s += 1
        while t[i_t] < _x:
            i_t += 1
        """
        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = s[i_s - 1], s[i_s]
        lt, rt = t[i_t - 1], t[i_t]
        r_max = max(rs, rt)
        l_min = min(ls, lt)
        x[_x] = min(
            [
                r_max - _x,
                _x - l_min,
                rt - ls + min(rt - _x, _x - ls),
                rs - lt + min(rs - _x, _x - lt),
            ]
        )
    return "\n".join([str(x[_x]) for _x in stx[-q:]])


if __name__ == "__main__":
    n, m, l = list(map(int, input().split()))
    print(
        (
            solve(
                "{} {} {}\n".format(n, m, l)
                + "\n".join([eval(input()) for _ in range(n + m + l)])
            )
        )
    )

-import bisect +from bisect import bisect_left -A, B, Q = list(map(int, input().split())) -INF = 10**18 -s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] -t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] -for q in range(Q): -    x = int(eval(input())) -    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) -    res = INF -    for S in [s[b - 1], s[b]]: -        for T in [t[d - 1], t[d]]: -            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) -            res = min(res, d1, d2) -    print(res) + +def solve(string): +    a, b, q, *stx = list(map(int, string.split())) +    s = [-(10**10)] + stx[:a] + [2 * 10**10] +    t = [-(10**10)] + stx[a : a + b] + [2 * 10**10] +    x = dict([]) +    i_s = 0 +    i_t = 0 +    for _x in sorted(set(stx[-q:])): +        """ +        while s[i_s] < _x: +            i_s += 1 +        while t[i_t] < _x: +            i_t += 1 +        """ +        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x) +        ls, rs = s[i_s - 1], s[i_s] +        lt, rt = t[i_t - 1], t[i_t] +        r_max = max(rs, rt) +        l_min = min(ls, lt) +        x[_x] = min( +            [ +                r_max - _x, +                _x - l_min, +                rt - ls + min(rt - _x, _x - ls), +                rs - lt + min(rs - _x, _x - lt), +            ] +        ) +    return "\n".join([str(x[_x]) for _x in stx[-q:]]) + + +if __name__ == "__main__": +    n, m, l = list(map(int, input().split())) +    print( +        ( +            solve( +                "{} {} {}\n".format(n, m, l) +                + "\n".join([eval(input()) for _ in range(n + m + l)]) +            ) +        ) +    )