#!/usr/bin/env python3
from bisect import bisect_right

def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans))

if __name__ == "__main__":
    main() from bisect import bisect_right def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans)) main A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () 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)] s = [-10**12] + s + [10**12] s [-10**12] + s + [10**12] [-10**12] + s [-10**12] -10**12 -10 12 s [10**12] 10**12 10 12 t = [-10**12] + t + [10**12] t [-10**12] + t + [10**12] [-10**12] + t [-10**12] -10**12 -10 12 t [10**12] 10**12 10 12 for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans)) _ range(Q) range Q x = int(input()) x int(input()) int input() input i = bisect_right(s,x) i bisect_right(s,x) bisect_right s x j = bisect_right(t,x) j bisect_right(t,x) bisect_right t x ans = [] ans [] ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x))) ans.append ans append max(abs(s[i-1] - x), abs(t[j-1] - x)) max abs(s[i-1] - x) abs s[i-1] - x s[i-1] s i-1 i 1 x abs(t[j-1] - x) abs t[j-1] - x t[j-1] t j-1 j 1 x ans.append(max(abs(s[i] - x), abs(t[j] - x))) ans.append ans append max(abs(s[i] - x), abs(t[j] - x)) max abs(s[i] - x) abs s[i] - x s[i] s i x abs(t[j] - x) abs t[j] - x t[j] t j x ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x))) ans.append ans append abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)) abs(s[i-1] - x) + abs(t[j] - x) abs(s[i-1] - x) abs s[i-1] - x s[i-1] s i-1 i 1 x abs(t[j] - x) abs t[j] - x t[j] t j x min(abs(s[i-1]-x), abs(t[j]-x)) min abs(s[i-1]-x) abs s[i-1]-x s[i-1] s i-1 i 1 x abs(t[j]-x) abs t[j]-x t[j] t j x ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x))) ans.append ans append abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)) abs(s[i] - x) + abs(t[j-1] - x) abs(s[i] - x) abs s[i] - x s[i] s i x abs(t[j-1] - x) abs t[j-1] - x t[j-1] t j-1 j 1 x min(abs(s[i]-x), abs(t[j-1]-x)) min abs(s[i]-x) abs s[i]-x s[i] s i x abs(t[j-1]-x) abs t[j-1]-x t[j-1] t j-1 j 1 x print(min(ans)) print min(ans) min ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans)) def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans)) main
#!/usr/bin/env python3
from bisect import bisect_right

def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans))

if __name__ == "__main__":
    main()
