import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')

INF = 10**12
d = lambda a, b: abs(a - b)


def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a)))


if __name__ == '__main__':
    main() import sys sys import bisect bisect read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline in_n = lambda: int(readline()) in_n lambda: int(readline()) int(readline()) int readline() readline in_nn = lambda: map(int, readline().split()) in_nn lambda: map(int, readline().split()) map(int, readline().split()) map int readline().split() ().split () readline split in_s = lambda: readline().rstrip().decode('utf-8') in_s lambda: readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' INF = 10**12 INF 10**12 10 12 d = lambda a, b: abs(a - b) d lambda a, b: abs(a - b) abs(a - b) abs a - b a b a b def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a))) main A, B, Q = in_nn() A in_nn() in_nn B Q tmp = list(map(int, read().split())) tmp list(map(int, read().split())) list map(int, read().split()) map int read().split() ().split () read split s = tmp[:A] s tmp[:A] tmp :A A t = tmp[A:A + B] t tmp[A:A + B] tmp A:A + B A A + B A B x = tmp[A + B:] x tmp[A + B:] tmp A + B: A + B A B a = [0] * Q a [0] * Q [0] 0 Q for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

     i range(Q) range Q n = x[i] n x[i] x i if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

         n <= s[0] n s[0] s 0 a1 = -INF a1 -INF INF a2 = s[0] a2 s[0] s 0 elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
         n >= s[-1] n s[-1] s -1 a1 = s[-1] a1 s[-1] s -1 a2 = INF a2 INF si = bisect.bisect_right(s, n) si bisect.bisect_right(s, n) bisect.bisect_right bisect bisect_right s n a1 = s[si - 1] a1 s[si - 1] s si - 1 si 1 a2 = s[si] a2 s[si] s si if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
         n <= t[0] n t[0] t 0 b1 = -INF b1 -INF INF b2 = t[0] b2 t[0] t 0 elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
         n >= t[-1] n t[-1] t -1 b1 = t[-1] b1 t[-1] t -1 b2 = INF b2 INF ti = bisect.bisect_right(t, n) ti bisect.bisect_right(t, n) bisect.bisect_right bisect bisect_right t n b1 = t[ti - 1] b1 t[ti - 1] t ti - 1 ti 1 b2 = t[ti] b2 t[ti] t ti ans = d(n, a1) + min(d(a1, b1), d(a1, b2)) ans d(n, a1) + min(d(a1, b1), d(a1, b2)) d(n, a1) d n a1 min(d(a1, b1), d(a1, b2)) min d(a1, b1) d a1 b1 d(a1, b2) d a1 b2 ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2))) ans min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2))) min ans d(n, a2) + min(d(a2, b1), d(a2, b2)) d(n, a2) d n a2 min(d(a2, b1), d(a2, b2)) min d(a2, b1) d a2 b1 d(a2, b2) d a2 b2 ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2))) ans min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2))) min ans d(n, b1) + min(d(b1, a1), d(b1, a2)) d(n, b1) d n b1 min(d(b1, a1), d(b1, a2)) min d(b1, a1) d b1 a1 d(b1, a2) d b1 a2 ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2))) ans min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2))) min ans d(n, b2) + min(d(b2, a1), d(b2, a2)) d(n, b2) d n b2 min(d(b2, a1), d(b2, a2)) min d(b2, a1) d b2 a1 d(b2, a2) d b2 a2 a[i] = ans a[i] a i ans print('\n'.join(map(str, a))) print '\n'.join(map(str, a)) '\n'.join '\n' join map(str, a) map str a if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.buffer.read sys.stdin.buffer.read read in_n = lambda: int(readline()) lambda: int(readline()) in_n d = lambda a, b: abs(a - b) lambda a, b: abs(a - b) d def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a))) def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a))) main in_nn = lambda: map(int, readline().split()) lambda: map(int, readline().split()) in_nn readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline INF = 10**12 10**12 INF in_s = lambda: readline().rstrip().decode('utf-8') lambda: readline().rstrip().decode('utf-8') in_s
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')

INF = 10**12
d = lambda a, b: abs(a - b)


def main():

    A, B, Q = in_nn()
    tmp = list(map(int, read().split()))
    s = tmp[:A]
    t = tmp[A:A + B]
    x = tmp[A + B:]

    a = [0] * Q

    for i in range(Q):

        n = x[i]

        if n <= s[0]:
            a1 = -INF
            a2 = s[0]
        elif n >= s[-1]:
            a1 = s[-1]
            a2 = INF
        else:
            si = bisect.bisect_right(s, n)
            a1 = s[si - 1]
            a2 = s[si]

        if n <= t[0]:
            b1 = -INF
            b2 = t[0]
        elif n >= t[-1]:
            b1 = t[-1]
            b2 = INF
        else:
            ti = bisect.bisect_right(t, n)
            b1 = t[ti - 1]
            b2 = t[ti]

        # print(a1, a2, b1, b2)
        ans = d(n, a1) + min(d(a1, b1), d(a1, b2))
        ans = min(ans, d(n, a2) + min(d(a2, b1), d(a2, b2)))
        ans = min(ans, d(n, b1) + min(d(b1, a1), d(b1, a2)))
        ans = min(ans, d(n, b2) + min(d(b2, a1), d(b2, a2)))
        a[i] = ans

    print('\n'.join(map(str, a)))


if __name__ == '__main__':
    main()
