import sys
from bisect import bisect_left

A, B, Q = map(int, sys.stdin.readline().split())
S = []
for _ in range(A):
    S.append(int(sys.stdin.readline()))
T = []
for _ in range(B):
    T.append(int(sys.stdin.readline()))

# S.sort()
# T.sort()
for _ in range(Q):
    x = int(sys.stdin.readline())

    #print("x", x)
    # 前後の神社、寺の距離を求める
    s_pos = bisect_left(S, x)
    if s_pos == 0:
        s_left = -float("inf")
    else:
        s_left = S[s_pos-1]
    if s_pos == A:
        s_right = float("inf")
    else:
        s_right = S[s_pos]
    #print("s", s_left, s_right)

    t_pos = bisect_left(T, x)
    if t_pos == 0:
        t_left = -float("inf")
    else:
        t_left = T[t_pos-1]
    if t_pos == B:
        t_right = float("inf")
    else:
        t_right = T[t_pos]
    #print("t", t_left, t_right)

    left_min = min(x - s_left, x - t_left)
    left_max = max(x - s_left, x - t_left)
    right_min = min(s_right - x, t_right - x)
    right_max = max(s_right - x, t_right - x)
    print(min(left_max, right_max,
                2 * (x - s_left) + (t_right - x), 2 * (x - t_left) + (s_right - x),
                2 * (t_right - x) + (x - s_left), 2 * (s_right - x) + (x - t_left))) import sys sys from bisect import bisect_left A, B, Q = map(int, sys.stdin.readline().split()) A map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split B Q S = [] S [] for _ in range(A):
    S.append(int(sys.stdin.readline())) _ range(A) range A S.append(int(sys.stdin.readline())) S.append S append int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline T = [] T [] for _ in range(B):
    T.append(int(sys.stdin.readline()))

# S.sort()
# T.sort() _ range(B) range B T.append(int(sys.stdin.readline())) T.append T append int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline for _ in range(Q):
    x = int(sys.stdin.readline())

    #print("x", x)
    # 前後の神社、寺の距離を求める
    s_pos = bisect_left(S, x)
    if s_pos == 0:
        s_left = -float("inf")
    else:
        s_left = S[s_pos-1]
    if s_pos == A:
        s_right = float("inf")
    else:
        s_right = S[s_pos]
    #print("s", s_left, s_right)

    t_pos = bisect_left(T, x)
    if t_pos == 0:
        t_left = -float("inf")
    else:
        t_left = T[t_pos-1]
    if t_pos == B:
        t_right = float("inf")
    else:
        t_right = T[t_pos]
    #print("t", t_left, t_right)

    left_min = min(x - s_left, x - t_left)
    left_max = max(x - s_left, x - t_left)
    right_min = min(s_right - x, t_right - x)
    right_max = max(s_right - x, t_right - x)
    print(min(left_max, right_max,
                2 * (x - s_left) + (t_right - x), 2 * (x - t_left) + (s_right - x),
                2 * (t_right - x) + (x - s_left), 2 * (s_right - x) + (x - t_left))) _ range(Q) range Q x = int(sys.stdin.readline()) x int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline s_pos = bisect_left(S, x) s_pos bisect_left(S, x) bisect_left S x if s_pos == 0:
        s_left = -float("inf")
    else:
        s_left = S[s_pos-1]
     s_pos == 0 s_pos 0 s_left = -float("inf") s_left -float("inf") float("inf") float "inf" s_left = S[s_pos-1] s_left S[s_pos-1] S s_pos-1 s_pos 1 if s_pos == A:
        s_right = float("inf")
    else:
        s_right = S[s_pos]
    #print("s", s_left, s_right)

     s_pos == A s_pos A s_right = float("inf") s_right float("inf") float "inf" s_right = S[s_pos] s_right S[s_pos] S s_pos t_pos = bisect_left(T, x) t_pos bisect_left(T, x) bisect_left T x if t_pos == 0:
        t_left = -float("inf")
    else:
        t_left = T[t_pos-1]
     t_pos == 0 t_pos 0 t_left = -float("inf") t_left -float("inf") float("inf") float "inf" t_left = T[t_pos-1] t_left T[t_pos-1] T t_pos-1 t_pos 1 if t_pos == B:
        t_right = float("inf")
    else:
        t_right = T[t_pos]
    #print("t", t_left, t_right)

     t_pos == B t_pos B t_right = float("inf") t_right float("inf") float "inf" t_right = T[t_pos] t_right T[t_pos] T t_pos left_min = min(x - s_left, x - t_left) left_min min(x - s_left, x - t_left) min x - s_left x s_left x - t_left x t_left left_max = max(x - s_left, x - t_left) left_max max(x - s_left, x - t_left) max x - s_left x s_left x - t_left x t_left right_min = min(s_right - x, t_right - x) right_min min(s_right - x, t_right - x) min s_right - x s_right x t_right - x t_right x right_max = max(s_right - x, t_right - x) right_max max(s_right - x, t_right - x) max s_right - x s_right x t_right - x t_right x print(min(left_max, right_max,
                2 * (x - s_left) + (t_right - x), 2 * (x - t_left) + (s_right - x),
                2 * (t_right - x) + (x - s_left), 2 * (s_right - x) + (x - t_left))) print min(left_max, right_max,
                2 * (x - s_left) + (t_right - x), 2 * (x - t_left) + (s_right - x),
                2 * (t_right - x) + (x - s_left), 2 * (s_right - x) + (x - t_left)) min left_max right_max 2 * (x - s_left) + (t_right - x) 2 * (x - s_left) 2 x - s_left x s_left t_right - x t_right x 2 * (x - t_left) + (s_right - x) 2 * (x - t_left) 2 x - t_left x t_left s_right - x s_right x 2 * (t_right - x) + (x - s_left) 2 * (t_right - x) 2 t_right - x t_right x x - s_left x s_left 2 * (s_right - x) + (x - t_left) 2 * (s_right - x) 2 s_right - x s_right x x - t_left x t_left B, Q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) B s_left = S[s_pos-1] S[s_pos-1] s_left s_right = float("inf") float("inf") s_right left_max = max(x - s_left, x - t_left) max(x - s_left, x - t_left) left_max A, B, Q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) A s_pos = bisect_left(S, x) bisect_left(S, x) s_pos t_pos = bisect_left(T, x) bisect_left(T, x) t_pos t_right = T[t_pos] T[t_pos] t_right Q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) Q s_right = S[s_pos] S[s_pos] s_right t_right = float("inf") float("inf") t_right right_min = min(s_right - x, t_right - x) min(s_right - x, t_right - x) right_min S = [] [] S T = [] [] T left_min = min(x - s_left, x - t_left) min(x - s_left, x - t_left) left_min x = int(sys.stdin.readline()) int(sys.stdin.readline()) x right_max = max(s_right - x, t_right - x) max(s_right - x, t_right - x) right_max t_left = T[t_pos-1] T[t_pos-1] t_left s_left = -float("inf") -float("inf") s_left t_left = -float("inf") -float("inf") t_left
import sys
from bisect import bisect_left

A, B, Q = map(int, sys.stdin.readline().split())
S = []
for _ in range(A):
    S.append(int(sys.stdin.readline()))
T = []
for _ in range(B):
    T.append(int(sys.stdin.readline()))

# S.sort()
# T.sort()
for _ in range(Q):
    x = int(sys.stdin.readline())

    #print("x", x)
    # 前後の神社、寺の距離を求める
    s_pos = bisect_left(S, x)
    if s_pos == 0:
        s_left = -float("inf")
    else:
        s_left = S[s_pos-1]
    if s_pos == A:
        s_right = float("inf")
    else:
        s_right = S[s_pos]
    #print("s", s_left, s_right)

    t_pos = bisect_left(T, x)
    if t_pos == 0:
        t_left = -float("inf")
    else:
        t_left = T[t_pos-1]
    if t_pos == B:
        t_right = float("inf")
    else:
        t_right = T[t_pos]
    #print("t", t_left, t_right)

    left_min = min(x - s_left, x - t_left)
    left_max = max(x - s_left, x - t_left)
    right_min = min(s_right - x, t_right - x)
    right_max = max(s_right - x, t_right - x)
    print(min(left_max, right_max,
                2 * (x - s_left) + (t_right - x), 2 * (x - t_left) + (s_right - x),
                2 * (t_right - x) + (x - s_left), 2 * (s_right - x) + (x - t_left)))