import sys
readline = sys.stdin.readline
from bisect import bisect_left
INF = 10 ** 11

def main():
    A, B, Q = map(int, readline().rstrip().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]

    for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res)


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline from bisect import bisect_left INF = 10 ** 11 INF 10 ** 11 10 11 def main():
    A, B, Q = map(int, readline().rstrip().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]

    for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res) main A, B, Q = map(int, readline().rstrip().split()) A map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split B Q int(readline()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(readline()) int readline() readline S = [int(readline()) for _ in range(A)] S [int(readline()) for _ in range(A)] int(readline()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(readline()) int readline() readline T = [int(readline()) for _ in range(B)] T [int(readline()) for _ in range(B)] for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res) _ range(Q) range Q x = int(readline()) x int(readline()) int readline() readline s_right_idx = bisect_left(S, x) s_right_idx bisect_left(S, x) bisect_left S x if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
         s_right_idx == 0 s_right_idx 0 s_right = S[s_right_idx] s_right S[s_right_idx] S s_right_idx s_left = -INF s_left -INF INF elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
         s_right_idx == A s_right_idx A s_left = S[s_right_idx-1] s_left S[s_right_idx-1] S s_right_idx-1 s_right_idx 1 s_right = INF s_right INF s_left,  s_right = S[s_right_idx - 1], S[s_right_idx] s_left S[s_right_idx - 1] S s_right_idx - 1 s_right_idx 1 s_right S[s_right_idx] S s_right_idx t_right_idx = bisect_left(T, x) t_right_idx bisect_left(T, x) bisect_left T x if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

         t_right_idx == 0 t_right_idx 0 t_right = T[t_right_idx] t_right T[t_right_idx] T t_right_idx t_left = -INF t_left -INF INF elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
         t_right_idx == B t_right_idx B t_left = T[t_right_idx-1] t_left T[t_right_idx-1] T t_right_idx-1 t_right_idx 1 t_right = INF t_right INF t_left,  t_right = T[t_right_idx - 1], T[t_right_idx] t_left T[t_right_idx - 1] T t_right_idx - 1 t_right_idx 1 t_right T[t_right_idx] T t_right_idx s_left_d, s_right_d = x - s_left, s_right - x s_left_d x - s_left x s_left s_right_d s_right - x s_right x t_left_d, t_right_d = x - t_left, t_right - x t_left_d x - t_left x t_left t_right_d t_right - x t_right x res1 = max(s_right_d, t_right_d) res1 max(s_right_d, t_right_d) max s_right_d t_right_d res2 = max(s_left_d, t_left_d) res2 max(s_left_d, t_left_d) max s_left_d t_left_d res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d) res3 min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d) min s_right_d * 2 + t_left_d s_right_d * 2 s_right_d 2 t_left_d t_right_d * 2 + s_left_d t_right_d * 2 t_right_d 2 s_left_d res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2) res4 min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2) min s_right_d + t_left_d * 2 s_right_d t_left_d * 2 t_left_d 2 t_right_d + s_left_d * 2 t_right_d s_left_d * 2 s_left_d 2 res = min(res1, res2, res3, res4) res min(res1, res2, res3, res4) min res1 res2 res3 res4 print(res) print res if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    A, B, Q = map(int, readline().rstrip().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]

    for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res) def main():
    A, B, Q = map(int, readline().rstrip().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]

    for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res) main readline = sys.stdin.readline sys.stdin.readline readline INF = 10 ** 11 10 ** 11 INF
import sys
readline = sys.stdin.readline
from bisect import bisect_left
INF = 10 ** 11

def main():
    A, B, Q = map(int, readline().rstrip().split())
    S = [int(readline()) for _ in range(A)]
    T = [int(readline()) for _ in range(B)]

    for _ in range(Q):
        x = int(readline())
        s_right_idx = bisect_left(S, x)
        if s_right_idx == 0:
            s_right = S[s_right_idx]
            s_left = -INF
        elif s_right_idx == A:
            s_left = S[s_right_idx-1]
            s_right = INF
        else:
            s_left,  s_right = S[s_right_idx - 1], S[s_right_idx]
        
        t_right_idx = bisect_left(T, x)
        if t_right_idx == 0:
            t_right = T[t_right_idx]
            t_left = -INF
        elif t_right_idx == B:
            t_left = T[t_right_idx-1]
            t_right = INF
        else:
            t_left,  t_right = T[t_right_idx - 1], T[t_right_idx]

        s_left_d, s_right_d = x - s_left, s_right - x
        t_left_d, t_right_d = x - t_left, t_right - x

        res1 = max(s_right_d, t_right_d)
        res2 = max(s_left_d, t_left_d)
        res3 = min(s_right_d * 2 + t_left_d, t_right_d * 2 + s_left_d)
        res4 = min(s_right_d + t_left_d * 2, t_right_d + s_left_d * 2)
        res = min(res1, res2, res3, res4)
        print(res)


if __name__ == '__main__':
    main()