import sys
import bisect
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)]
s = sorted(s)
t = sorted(t)

for _ in range(Q):
    x = int(input())
    idx1 = bisect.bisect_right(s, x)
    idx2 = bisect.bisect_right(t, x)
    ans = float('inf')
    if idx1 > 0:
        left_s = s[idx1-1]
    else:
        left_s = float('inf')
    if idx2 > 0:
        left_t = t[idx2-1]
    else:
        left_t = float('inf')
    if idx1 < A:
        right_s = s[idx1]
    else:
        right_s = float('inf')
    if idx2 < B:
        right_t = t[idx2]
    else:
        right_t = float('inf')

    ls = x-left_s
    lt = x-left_t
    rs = right_s-x
    rt = right_t-x 
    if left_s <= x <= right_t:
        tmp = right_t-left_s + min(ls, rt)
        ans = min(ans, tmp)
    if left_t <= x <= right_s:
        tmp = right_s-left_t + min(lt, rs)
        ans = min(ans, tmp)
    ans = min(ans, max(abs(ls), abs(lt)))
    ans = min(ans, max(abs(rs), abs(rt)))
    print(ans) import sys sys import bisect bisect 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)] s = sorted(s) s sorted(s) sorted s t = sorted(t) t sorted(t) sorted t for _ in range(Q):
    x = int(input())
    idx1 = bisect.bisect_right(s, x)
    idx2 = bisect.bisect_right(t, x)
    ans = float('inf')
    if idx1 > 0:
        left_s = s[idx1-1]
    else:
        left_s = float('inf')
    if idx2 > 0:
        left_t = t[idx2-1]
    else:
        left_t = float('inf')
    if idx1 < A:
        right_s = s[idx1]
    else:
        right_s = float('inf')
    if idx2 < B:
        right_t = t[idx2]
    else:
        right_t = float('inf')

    ls = x-left_s
    lt = x-left_t
    rs = right_s-x
    rt = right_t-x 
    if left_s <= x <= right_t:
        tmp = right_t-left_s + min(ls, rt)
        ans = min(ans, tmp)
    if left_t <= x <= right_s:
        tmp = right_s-left_t + min(lt, rs)
        ans = min(ans, tmp)
    ans = min(ans, max(abs(ls), abs(lt)))
    ans = min(ans, max(abs(rs), abs(rt)))
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input idx1 = bisect.bisect_right(s, x) idx1 bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x idx2 = bisect.bisect_right(t, x) idx2 bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x ans = float('inf') ans float('inf') float 'inf' if idx1 > 0:
        left_s = s[idx1-1]
    else:
        left_s = float('inf')
     idx1 > 0 idx1 0 left_s = s[idx1-1] left_s s[idx1-1] s idx1-1 idx1 1 left_s = float('inf') left_s float('inf') float 'inf' if idx2 > 0:
        left_t = t[idx2-1]
    else:
        left_t = float('inf')
     idx2 > 0 idx2 0 left_t = t[idx2-1] left_t t[idx2-1] t idx2-1 idx2 1 left_t = float('inf') left_t float('inf') float 'inf' if idx1 < A:
        right_s = s[idx1]
    else:
        right_s = float('inf')
     idx1 < A idx1 A right_s = s[idx1] right_s s[idx1] s idx1 right_s = float('inf') right_s float('inf') float 'inf' if idx2 < B:
        right_t = t[idx2]
    else:
        right_t = float('inf')

     idx2 < B idx2 B right_t = t[idx2] right_t t[idx2] t idx2 right_t = float('inf') right_t float('inf') float 'inf' ls = x-left_s ls x-left_s x left_s lt = x-left_t lt x-left_t x left_t rs = right_s-x rs right_s-x right_s x rt = right_t-x rt right_t-x right_t x if left_s <= x <= right_t:
        tmp = right_t-left_s + min(ls, rt)
        ans = min(ans, tmp)
     left_s <= x <= right_t left_s <= x left_s x right_t tmp = right_t-left_s + min(ls, rt) tmp right_t-left_s + min(ls, rt) right_t-left_s right_t left_s min(ls, rt) min ls rt ans = min(ans, tmp) ans min(ans, tmp) min ans tmp if left_t <= x <= right_s:
        tmp = right_s-left_t + min(lt, rs)
        ans = min(ans, tmp)
     left_t <= x <= right_s left_t <= x left_t x right_s tmp = right_s-left_t + min(lt, rs) tmp right_s-left_t + min(lt, rs) right_s-left_t right_s left_t min(lt, rs) min lt rs ans = min(ans, tmp) ans min(ans, tmp) min ans tmp ans = min(ans, max(abs(ls), abs(lt))) ans min(ans, max(abs(ls), abs(lt))) min ans max(abs(ls), abs(lt)) max abs(ls) abs ls abs(lt) abs lt ans = min(ans, max(abs(rs), abs(rt))) ans min(ans, max(abs(rs), abs(rt))) min ans max(abs(rs), abs(rt)) max abs(rs) abs rs abs(rt) abs rt print(ans) print ans left_s = s[idx1-1] s[idx1-1] left_s left_t = float('inf') float('inf') left_t right_s = s[idx1] s[idx1] right_s right_t = t[idx2] t[idx2] right_t ls = x-left_s x-left_s ls ans = min(ans, tmp) min(ans, tmp) ans B, Q = map(int, input().split()) map(int, input().split()) B input = sys.stdin.readline sys.stdin.readline input ans = float('inf') float('inf') ans left_s = float('inf') float('inf') left_s tmp = right_s-left_t + min(lt, rs) right_s-left_t + min(lt, rs) tmp rs = right_s-x right_s-x rs t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s right_s = float('inf') float('inf') right_s rt = right_t-x right_t-x rt lt = x-left_t x-left_t lt ans = min(ans, max(abs(ls), abs(lt))) min(ans, max(abs(ls), abs(lt))) ans s = sorted(s) sorted(s) s ans = min(ans, max(abs(rs), abs(rt))) min(ans, max(abs(rs), abs(rt))) ans idx2 = bisect.bisect_right(t, x) bisect.bisect_right(t, x) idx2 x = int(input()) int(input()) x left_t = t[idx2-1] t[idx2-1] left_t right_t = float('inf') float('inf') right_t ans = min(ans, tmp) min(ans, tmp) ans idx1 = bisect.bisect_right(s, x) bisect.bisect_right(s, x) idx1 t = sorted(t) sorted(t) t Q = map(int, input().split()) map(int, input().split()) Q A, B, Q = map(int, input().split()) map(int, input().split()) A tmp = right_t-left_s + min(ls, rt) right_t-left_s + min(ls, rt) tmp
import sys
import bisect
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)]
s = sorted(s)
t = sorted(t)

for _ in range(Q):
    x = int(input())
    idx1 = bisect.bisect_right(s, x)
    idx2 = bisect.bisect_right(t, x)
    ans = float('inf')
    if idx1 > 0:
        left_s = s[idx1-1]
    else:
        left_s = float('inf')
    if idx2 > 0:
        left_t = t[idx2-1]
    else:
        left_t = float('inf')
    if idx1 < A:
        right_s = s[idx1]
    else:
        right_s = float('inf')
    if idx2 < B:
        right_t = t[idx2]
    else:
        right_t = float('inf')

    ls = x-left_s
    lt = x-left_t
    rs = right_s-x
    rt = right_t-x 
    if left_s <= x <= right_t:
        tmp = right_t-left_s + min(ls, rt)
        ans = min(ans, tmp)
    if left_t <= x <= right_s:
        tmp = right_s-left_t + min(lt, rs)
        ans = min(ans, tmp)
    ans = min(ans, max(abs(ls), abs(lt)))
    ans = min(ans, max(abs(rs), abs(rt)))
    print(ans)
