import sys
import bisect

input = sys.stdin.readline


def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6))


if __name__ == '__main__':
    main() import sys sys import bisect bisect input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6)) main int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x A, B, Q = [int(x) for x in input().split()] A [int(x) for x in input().split()] B Q int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input S = [int(input()) for _ in range(A)] S [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input T = [int(input()) for _ in range(B)] T [int(input()) for _ in range(B)] for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6)) _ range(Q) range Q x = int(input()) x int(input()) int input() input si = bisect.bisect_left(S, x) si bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x ti = bisect.bisect_left(T, x) ti bisect.bisect_left(T, x) bisect.bisect_left bisect bisect_left T x sl = -float("inf") sl -float("inf") float("inf") float "inf" if si != 0:
            sl = S[si - 1]
         si != 0 si 0 sl = S[si - 1] sl S[si - 1] S si - 1 si 1 sr = float("inf") sr float("inf") float "inf" if si != A:
            sr = S[si]
         si != A si A sr = S[si] sr S[si] S si tl = -float("inf") tl -float("inf") float("inf") float "inf" if ti != 0:
            tl = T[ti - 1]
         ti != 0 ti 0 tl = T[ti - 1] tl T[ti - 1] T ti - 1 ti 1 tr = float("inf") tr float("inf") float "inf" if ti != B:
            tr = T[ti]

         ti != B ti B tr = T[ti] tr T[ti] T ti tmp1 = max(x - sl, x - tl) tmp1 max(x - sl, x - tl) max x - sl x sl x - tl x tl tmp2 = max(sr, tr) - x tmp2 max(sr, tr) - x max(sr, tr) max sr tr x tmp3 = 2 * (x - sl) + tr - x tmp3 2 * (x - sl) + tr - x 2 * (x - sl) + tr 2 * (x - sl) 2 x - sl x sl tr x tmp4 = 2 * (x - tl) + sr - x tmp4 2 * (x - tl) + sr - x 2 * (x - tl) + sr 2 * (x - tl) 2 x - tl x tl sr x tmp5 = x - sl + 2 * (tr - x) tmp5 x - sl + 2 * (tr - x) x - sl x sl 2 * (tr - x) 2 tr - x tr x tmp6 = x - tl + 2 * (sr - x) tmp6 x - tl + 2 * (sr - x) x - tl x tl 2 * (sr - x) 2 sr - x sr x print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6)) print min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6) min tmp1 tmp2 tmp3 tmp4 tmp5 tmp6 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = sys.stdin.readline sys.stdin.readline input def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6)) def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6)) main
import sys
import bisect

input = sys.stdin.readline


def main():
    A, B, Q = [int(x) for x in input().split()]
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect.bisect_left(S, x)
        ti = bisect.bisect_left(T, x)
        sl = -float("inf")
        if si != 0:
            sl = S[si - 1]
        sr = float("inf")
        if si != A:
            sr = S[si]
        tl = -float("inf")
        if ti != 0:
            tl = T[ti - 1]
        tr = float("inf")
        if ti != B:
            tr = T[ti]

        tmp1 = max(x - sl, x - tl)
        tmp2 = max(sr, tr) - x
        tmp3 = 2 * (x - sl) + tr - x
        tmp4 = 2 * (x - tl) + sr - x
        tmp5 = x - sl + 2 * (tr - x)
        tmp6 = x - tl + 2 * (sr - x)

        print(min(tmp1, tmp2, tmp3, tmp4, tmp5, tmp6))


if __name__ == '__main__':
    main()
