from bisect import bisect_left, bisect_right

a, b, q = list(map(int, input().split()))

s = [int(eval(input())) for _ in range(a)]

t = [int(eval(input())) for _ in range(b)]

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

for qi in q:

    qans = 10**18

    ai = bisect_left(s, qi)

    bi = bisect_left(t, qi)

    ac = []

    bc = []

    for i in range(2):

        if (0 <= ai + i < a):

            ac.append(ai + i);

        if (0 <= ai - i < a):

            ac.append(ai - i);

    for i in range(2):

        if (0 <= bi + i < b):

            bc.append(bi + i);

        if (0 <= bi - i < b):

            bc.append(bi - i);

    for i in ac:

        for j in bc:

            aa = s[i];

            bb = t[j];

            if (max(aa, bb) <= qi):

                qans = min(qans, qi - min(aa, bb))

            elif (qi <= min(aa, bb)):

                qans = min(qans, max(aa, bb) - qi)

            else:

                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))

    print(qans)

from bisect import bisect_left, bisect_right

import sys

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

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

for qi in q:

    qans = 10**18

    ai = bisect_left(s, qi)

    bi = bisect_left(t, qi)

    ac = []

    bc = []

    for i in range(2):

        if (0 <= ai + i < a):

            ac.append(ai + i);

        if (0 <= ai - i < a):

            ac.append(ai - i);

    for i in range(2):

        if (0 <= bi + i < b):

            bc.append(bi + i);

        if (0 <= bi - i < b):

            bc.append(bi - i);

    for i in ac:

        for j in bc:

            aa = s[i];

            bb = t[j];

            if (max(aa, bb) <= qi):

                qans = min(qans, qi - min(aa, bb))

            elif (qi <= min(aa, bb)):

                qans = min(qans, max(aa, bb) - qi)

            else:

                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))

    print(qans)

from bisect import bisect_left, bisect_right

a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if 0 <= ai + i < a:
            ac.append(ai + i)
        if 0 <= ai - i < a:
            ac.append(ai - i)
    for i in range(2):
        if 0 <= bi + i < b:
            bc.append(bi + i)
        if 0 <= bi - i < b:
            bc.append(bi - i)
    for i in ac:
        for j in bc:
            aa = s[i]
            bb = t[j]
            if max(aa, bb) <= qi:
                qans = min(qans, qi - min(aa, bb))
            elif qi <= min(aa, bb):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(
                    qans,
                    min(abs(aa - qi), abs(bb - qi)) * 2
                    + max(abs(aa - qi), abs(bb - qi)),
                )
    print(qans)

from bisect import bisect_left, bisect_right
import sys

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)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if 0 <= ai + i < a:
            ac.append(ai + i)
        if 0 <= ai - i < a:
            ac.append(ai - i)
    for i in range(2):
        if 0 <= bi + i < b:
            bc.append(bi + i)
        if 0 <= bi - i < b:
            bc.append(bi - i)
    for i in ac:
        for j in bc:
            aa = s[i]
            bb = t[j]
            if max(aa, bb) <= qi:
                qans = min(qans, qi - min(aa, bb))
            elif qi <= min(aa, bb):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(
                    qans,
                    min(abs(aa - qi), abs(bb - qi)) * 2
                    + max(abs(aa - qi), abs(bb - qi)),
                )
    print(qans)

+import sys +input = sys.stdin.readline