A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
query, X = [], {}

for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i
query.sort()

near_s = [0 for _ in range(Q)]
near_t = [0 for _ in range(Q)]
j = 0
while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1    
for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1
near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)]

j = 0
while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1
for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1
near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)]

ans = [0]*Q
for i in range(Q):
    q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4)

for a in ans:
    print(a) 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)] query, X = [], {} query [] X {} for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i i range(Q) range Q q = int(input()) q int(input()) int input() input query.append(q) query.append query append q X[q] = i X[q] X q i query.sort() query.sort query sort 0 for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) 0 near_s = [0 for _ in range(Q)] near_s [0 for _ in range(Q)] 0 for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) 0 near_t = [0 for _ in range(Q)] near_t [0 for _ in range(Q)] j = 0 j 0 while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1     j < Q and query[j] < S[0] j < Q j Q query[j] < S[0] query[j] query j S[0] S 0 near_s[j] = [0, S[0]] near_s[j] near_s j [0, S[0]] 0 S[0] S 0 j += 1 j 1 for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1 i range(A-1) range A-1 A 1 while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1 j < Q and S[i] < query[j] < S[i+1] j < Q j Q S[i] < query[j] < S[i+1] S[i] < query[j] S[i] S i query[j] query j S[i+1] S i+1 i 1 near_s[j] = [S[i], S[i+1]] near_s[j] near_s j [S[i], S[i+1]] S[i] S i S[i+1] S i+1 i 1 j += 1 j 1 [S[A-1],0] for _ in range(Q-j) for _ in range(Q-j) _ range(Q-j) range Q-j Q j for _ in range(Q-j) [S[A-1],0] S[A-1] S A-1 A 1 0 near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)] near_s near_s[:j] + [[S[A-1],0] for _ in range(Q-j)] near_s[:j] near_s :j j [[S[A-1],0] for _ in range(Q-j)] j = 0 j 0 while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1 j < Q and query[j] < T[0] j < Q j Q query[j] < T[0] query[j] query j T[0] T 0 near_t[j] = [0, T[0]] near_t[j] near_t j [0, T[0]] 0 T[0] T 0 j += 1 j 1 for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1 i range(B-1) range B-1 B 1 while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1 j < Q and T[i] < query[j] < T[i+1] j < Q j Q T[i] < query[j] < T[i+1] T[i] < query[j] T[i] T i query[j] query j T[i+1] T i+1 i 1 near_t[j] = [T[i], T[i+1]] near_t[j] near_t j [T[i], T[i+1]] T[i] T i T[i+1] T i+1 i 1 j += 1 j 1 [T[B-1],0] for _ in range(Q-j) for _ in range(Q-j) _ range(Q-j) range Q-j Q j for _ in range(Q-j) [T[B-1],0] T[B-1] T B-1 B 1 0 near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)] near_t near_t[:j] + [[T[B-1],0] for _ in range(Q-j)] near_t[:j] near_t :j j [[T[B-1],0] for _ in range(Q-j)] ans = [0]*Q ans [0]*Q [0] 0 Q for i in range(Q):
    q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4) i range(Q) range Q q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] q query[i] query i s0 near_s[i][0] [i] near_s i 0 s1 near_s[i][1] [i] near_s i 1 t0 near_t[i][0] [i] near_t i 0 t1 near_t[i][1] [i] near_t i 1 l1 = q - min(s0, t0) l1 q - min(s0, t0) q min(s0, t0) min s0 t0 l2 = max(s1, t1) - q l2 max(s1, t1) - q max(s1, t1) max s1 t1 q l3 = s1 - t0 + min(s1 - q, q - t0) l3 s1 - t0 + min(s1 - q, q - t0) s1 - t0 s1 t0 min(s1 - q, q - t0) min s1 - q s1 q q - t0 q t0 l4 = t1 - s0 + min(t1 - q, q - s0) l4 t1 - s0 + min(t1 - q, q - s0) t1 - s0 t1 s0 min(t1 - q, q - s0) min t1 - q t1 q q - s0 q s0 if s0 == 0:
        l1, l4 = float('inf'), float('inf')
     s0 == 0 s0 0 l1, l4 = float('inf'), float('inf') l1 float('inf') float 'inf' l4 float('inf') float 'inf' if s1 == 0:
        l2, l3 = float('inf'), float('inf')
     s1 == 0 s1 0 l2, l3 = float('inf'), float('inf') l2 float('inf') float 'inf' l3 float('inf') float 'inf' if t0 == 0:
        l1, l3 = float('inf'), float('inf')
     t0 == 0 t0 0 l1, l3 = float('inf'), float('inf') l1 float('inf') float 'inf' l3 float('inf') float 'inf' if t1 == 0:
        l2, l4 = float('inf'), float('inf')
     t1 == 0 t1 0 l2, l4 = float('inf'), float('inf') l2 float('inf') float 'inf' l4 float('inf') float 'inf' ans[X[q]] = min(l1, l2, l3, l4) ans[X[q]] ans X[q] X q min(l1, l2, l3, l4) min l1 l2 l3 l4 for a in ans:
    print(a) a ans print(a) print a l3 = s1 - t0 + min(s1 - q, q - t0) s1 - t0 + min(s1 - q, q - t0) l3 A, B, Q = map(int, input().split()) map(int, input().split()) A near_t = [0 for _ in range(Q)] [0 for _ in range(Q)] near_t q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] query[i] q s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] near_s[i][1] s1 X = [], {} {} X near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)] near_s[:j] + [[S[A-1],0] for _ in range(Q-j)] near_s l1, l4 = float('inf'), float('inf') float('inf') l1 T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T l1 = q - min(s0, t0) q - min(s0, t0) l1 l4 = float('inf'), float('inf') float('inf') l4 l3 = float('inf'), float('inf') float('inf') l3 l2, l3 = float('inf'), float('inf') float('inf') l2 l2, l4 = float('inf'), float('inf') float('inf') l2 j += 1 1 j q = int(input()) int(input()) q ans = [0]*Q [0]*Q ans j += 1 1 j Q = map(int, input().split()) map(int, input().split()) Q query, X = [], {} [] query j += 1 1 j l4 = t1 - s0 + min(t1 - q, q - s0) t1 - s0 + min(t1 - q, q - s0) l4 j += 1 1 j t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] near_t[i][0] t0 B, Q = map(int, input().split()) map(int, input().split()) B S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S l2 = max(s1, t1) - q max(s1, t1) - q l2 l1, l3 = float('inf'), float('inf') float('inf') l1 l3 = float('inf'), float('inf') float('inf') l3 j = 0 0 j near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)] near_t[:j] + [[T[B-1],0] for _ in range(Q-j)] near_t s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] near_s[i][0] s0 t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1] near_t[i][1] t1 near_s = [0 for _ in range(Q)] [0 for _ in range(Q)] near_s j = 0 0 j l4 = float('inf'), float('inf') float('inf') l4
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
query, X = [], {}

for i in range(Q):
    q = int(input())
    query.append(q)
    X[q] = i
query.sort()

near_s = [0 for _ in range(Q)]
near_t = [0 for _ in range(Q)]
j = 0
while j < Q and query[j] < S[0]:
    near_s[j] = [0, S[0]]
    j += 1    
for i in range(A-1):
    while j < Q and S[i] < query[j] < S[i+1]:
        near_s[j] = [S[i], S[i+1]]
        j += 1
near_s = near_s[:j] + [[S[A-1],0] for _ in range(Q-j)]

j = 0
while j < Q and query[j] < T[0]:
    near_t[j] = [0, T[0]]
    j += 1
for i in range(B-1):
    while j < Q and T[i] < query[j] < T[i+1]:
        near_t[j] = [T[i], T[i+1]]
        j += 1
near_t = near_t[:j] + [[T[B-1],0] for _ in range(Q-j)]

ans = [0]*Q
for i in range(Q):
    q, s0, s1, t0, t1 = query[i], near_s[i][0], near_s[i][1], near_t[i][0], near_t[i][1]
    l1 = q - min(s0, t0)
    l2 = max(s1, t1) - q
    l3 = s1 - t0 + min(s1 - q, q - t0)
    l4 = t1 - s0 + min(t1 - q, q - s0)
    if s0 == 0:
        l1, l4 = float('inf'), float('inf')
    if s1 == 0:
        l2, l3 = float('inf'), float('inf')
    if t0 == 0:
        l1, l3 = float('inf'), float('inf')
    if t1 == 0:
        l2, l4 = float('inf'), float('inf')
    ans[X[q]] = min(l1, l2, l3, l4)

for a in ans:
    print(a)