import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, 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_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0

if __name__ == "__main__":
    solve() import sys sys from bisect import bisect_left def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, 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_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0 solve input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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)] for _ in range(Q):
        x = int(input())
        si = bisect_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

     _ range(Q) range Q x = int(input()) x int(input()) int input() input si = bisect_left(S, x) si bisect_left(S, x) bisect_left S x ti = bisect_left(T, x) ti bisect_left(T, x) bisect_left T x minLength = 10 **20 minLength 10 **20 10 20 both_left = 10 ** 20 both_left 10 ** 20 10 20 both_right = 10 ** 20 both_right 10 ** 20 10 20 s_t = 10 ** 20 s_t 10 ** 20 10 20 t_s = 10 ** 20 t_s 10 ** 20 10 20 if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
         si > 0 and ti > 0 si > 0 si 0 ti > 0 ti 0 if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
         si <= A - 1 and ti <= B - 1 si <= A - 1 si A - 1 A 1 ti <= B - 1 ti B - 1 B 1 if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
         si > 0 and ti <= B - 1 si > 0 si 0 ti <= B - 1 ti B - 1 B 1 if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
         ti > 0 and si <= A - 1 ti > 0 ti 0 si <= A - 1 si A - 1 A 1 minLength = min([both_left, both_right, s_t, t_s]) minLength min([both_left, both_right, s_t, t_s]) min [both_left, both_right, s_t, t_s] both_left both_right s_t t_s print(minLength) print minLength return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, 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_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0 def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, 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_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0 solve
import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, 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_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0

if __name__ == "__main__":
    solve()