import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left

a, b, q = map(int, readline().split())
s = [int(readline()) for _ in range(a)]
t = [int(readline()) for _ in range(b)]
s.sort()
t.sort()
inf = float('inf')
for i in range(q):
    x = int(readline())
    ans = inf
    index_s = bisect_left(s, x)
    index_t = bisect_left(t, x)
    if index_s > 0 and index_t > 0:
        ans = min(ans, x - min(s[index_s - 1], t[index_t - 1]))
    if index_s < a and index_t < b:
        ans = min(ans, max(s[index_s], t[index_t]) - x)
    if index_s > 0 and index_t < b:
        ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2))
    if index_s < a and index_t > 0:
        ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2))
    print(ans) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from bisect import bisect_left a, b, q = map(int, readline().split()) a map(int, readline().split()) map int readline().split() ().split () readline 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)] s.sort() s.sort s sort t.sort() t.sort t sort inf = float('inf') inf float('inf') float 'inf' for i in range(q):
    x = int(readline())
    ans = inf
    index_s = bisect_left(s, x)
    index_t = bisect_left(t, x)
    if index_s > 0 and index_t > 0:
        ans = min(ans, x - min(s[index_s - 1], t[index_t - 1]))
    if index_s < a and index_t < b:
        ans = min(ans, max(s[index_s], t[index_t]) - x)
    if index_s > 0 and index_t < b:
        ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2))
    if index_s < a and index_t > 0:
        ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2))
    print(ans) i range(q) range q x = int(readline()) x int(readline()) int readline() readline ans = inf ans inf index_s = bisect_left(s, x) index_s bisect_left(s, x) bisect_left s x index_t = bisect_left(t, x) index_t bisect_left(t, x) bisect_left t x if index_s > 0 and index_t > 0:
        ans = min(ans, x - min(s[index_s - 1], t[index_t - 1]))
     index_s > 0 and index_t > 0 index_s > 0 index_s 0 index_t > 0 index_t 0 ans = min(ans, x - min(s[index_s - 1], t[index_t - 1])) ans min(ans, x - min(s[index_s - 1], t[index_t - 1])) min ans x - min(s[index_s - 1], t[index_t - 1]) x min(s[index_s - 1], t[index_t - 1]) min s[index_s - 1] s index_s - 1 index_s 1 t[index_t - 1] t index_t - 1 index_t 1 if index_s < a and index_t < b:
        ans = min(ans, max(s[index_s], t[index_t]) - x)
     index_s < a and index_t < b index_s < a index_s a index_t < b index_t b ans = min(ans, max(s[index_s], t[index_t]) - x) ans min(ans, max(s[index_s], t[index_t]) - x) min ans max(s[index_s], t[index_t]) - x max(s[index_s], t[index_t]) max s[index_s] s index_s t[index_t] t index_t x if index_s > 0 and index_t < b:
        ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2))
     index_s > 0 and index_t < b index_s > 0 index_s 0 index_t < b index_t b ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2)) ans min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2)) min ans min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2) min (x - s[index_s - 1]) * 2 + t[index_t] - x (x - s[index_s - 1]) * 2 + t[index_t] (x - s[index_s - 1]) * 2 x - s[index_s - 1] x s[index_s - 1] s index_s - 1 index_s 1 2 t[index_t] t index_t x x - s[index_s - 1] + (t[index_t] - x) * 2 x - s[index_s - 1] x s[index_s - 1] s index_s - 1 index_s 1 (t[index_t] - x) * 2 t[index_t] - x t[index_t] t index_t x 2 if index_s < a and index_t > 0:
        ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2))
     index_s < a and index_t > 0 index_s < a index_s a index_t > 0 index_t 0 ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2)) ans min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2)) min ans min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2) min (s[index_s] - x) * 2 + x - t[index_t - 1] (s[index_s] - x) * 2 + x (s[index_s] - x) * 2 s[index_s] - x s[index_s] s index_s x 2 x t[index_t - 1] t index_t - 1 index_t 1 s[index_s] - x + (x - t[index_t - 1]) * 2 s[index_s] - x s[index_s] s index_s x (x - t[index_t - 1]) * 2 x - t[index_t - 1] x t[index_t - 1] t index_t - 1 index_t 1 2 print(ans) print ans t = [int(readline()) for _ in range(b)] [int(readline()) for _ in range(b)] t index_t = bisect_left(t, x) bisect_left(t, x) index_t readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline index_s = bisect_left(s, x) bisect_left(s, x) index_s inf = float('inf') float('inf') inf ans = min(ans, x - min(s[index_s - 1], t[index_t - 1])) min(ans, x - min(s[index_s - 1], t[index_t - 1])) ans ans = min(ans, max(s[index_s], t[index_t]) - x) min(ans, max(s[index_s], t[index_t]) - x) ans s = [int(readline()) for _ in range(a)] [int(readline()) for _ in range(a)] s readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines q = map(int, readline().split()) map(int, readline().split()) q x = int(readline()) int(readline()) x b, q = map(int, readline().split()) map(int, readline().split()) b read = sys.stdin.buffer.read sys.stdin.buffer.read read ans = inf inf ans a, b, q = map(int, readline().split()) map(int, readline().split()) a ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2)) min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2)) ans ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2)) min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2)) ans
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left

a, b, q = map(int, readline().split())
s = [int(readline()) for _ in range(a)]
t = [int(readline()) for _ in range(b)]
s.sort()
t.sort()
inf = float('inf')
for i in range(q):
    x = int(readline())
    ans = inf
    index_s = bisect_left(s, x)
    index_t = bisect_left(t, x)
    if index_s > 0 and index_t > 0:
        ans = min(ans, x - min(s[index_s - 1], t[index_t - 1]))
    if index_s < a and index_t < b:
        ans = min(ans, max(s[index_s], t[index_t]) - x)
    if index_s > 0 and index_t < b:
        ans = min(ans, min((x - s[index_s - 1]) * 2 + t[index_t] - x, x - s[index_s - 1] + (t[index_t] - x) * 2))
    if index_s < a and index_t > 0:
        ans = min(ans, min((s[index_s] - x) * 2 + x - t[index_t - 1], s[index_s] - x + (x - t[index_t - 1]) * 2))
    print(ans)
