import bisect
a, b, q = map(int, input().split())

s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s.append(-100000000000)
s.append(100000000000)
t.append(-100000000000)
t.append(100000000000)
s.sort()
t.sort()

for _ in range(q):
    x = int(input())

    idxs = bisect.bisect_right(s, x)
    idxt = bisect.bisect_right(t, x)
    left_s = s[idxs - 1]
    right_s = s[idxs]
    left_t = t[idxt - 1]
    right_t = t[idxt]

    kouho1 = max(x - left_s, x - left_t)
    kouho2 = max(right_s - x, right_t - x)
    kouho3 = min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x)
    kouho4 = min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x)
    print(min(kouho1, kouho2, kouho3, kouho4)) import bisect bisect 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.append(-100000000000) s.append s append -100000000000 s.append(100000000000) s.append s append 100000000000 t.append(-100000000000) t.append t append -100000000000 t.append(100000000000) t.append t append 100000000000 s.sort() s.sort s sort t.sort() t.sort t sort for _ in range(q):
    x = int(input())

    idxs = bisect.bisect_right(s, x)
    idxt = bisect.bisect_right(t, x)
    left_s = s[idxs - 1]
    right_s = s[idxs]
    left_t = t[idxt - 1]
    right_t = t[idxt]

    kouho1 = max(x - left_s, x - left_t)
    kouho2 = max(right_s - x, right_t - x)
    kouho3 = min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x)
    kouho4 = min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x)
    print(min(kouho1, kouho2, kouho3, kouho4)) _ range(q) range q x = int(input()) x int(input()) int input() input idxs = bisect.bisect_right(s, x) idxs bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x idxt = bisect.bisect_right(t, x) idxt bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x left_s = s[idxs - 1] left_s s[idxs - 1] s idxs - 1 idxs 1 right_s = s[idxs] right_s s[idxs] s idxs left_t = t[idxt - 1] left_t t[idxt - 1] t idxt - 1 idxt 1 right_t = t[idxt] right_t t[idxt] t idxt kouho1 = max(x - left_s, x - left_t) kouho1 max(x - left_s, x - left_t) max x - left_s x left_s x - left_t x left_t kouho2 = max(right_s - x, right_t - x) kouho2 max(right_s - x, right_t - x) max right_s - x right_s x right_t - x right_t x kouho3 = min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x) kouho3 min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x) min(x - left_s, right_t - x) * 2 min(x - left_s, right_t - x) min x - left_s x left_s right_t - x right_t x 2 max(x - left_s, right_t - x) max x - left_s x left_s right_t - x right_t x kouho4 = min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x) kouho4 min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x) min(x - left_t, right_s - x) * 2 min(x - left_t, right_s - x) min x - left_t x left_t right_s - x right_s x 2 max(x - left_t, right_s - x) max x - left_t x left_t right_s - x right_s x print(min(kouho1, kouho2, kouho3, kouho4)) print min(kouho1, kouho2, kouho3, kouho4) min kouho1 kouho2 kouho3 kouho4 kouho4 = min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x) min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x) kouho4 a, b, q = map(int, input().split()) map(int, input().split()) a left_s = s[idxs - 1] s[idxs - 1] left_s idxs = bisect.bisect_right(s, x) bisect.bisect_right(s, x) idxs b, q = map(int, input().split()) map(int, input().split()) b right_s = s[idxs] s[idxs] right_s kouho3 = min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x) min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x) kouho3 kouho2 = max(right_s - x, right_t - x) max(right_s - x, right_t - x) kouho2 right_t = t[idxt] t[idxt] right_t x = int(input()) int(input()) x q = map(int, input().split()) map(int, input().split()) q idxt = bisect.bisect_right(t, x) bisect.bisect_right(t, x) idxt s = [int(input()) for _ in range(a)] [int(input()) for _ in range(a)] s t = [int(input()) for _ in range(b)] [int(input()) for _ in range(b)] t kouho1 = max(x - left_s, x - left_t) max(x - left_s, x - left_t) kouho1 left_t = t[idxt - 1] t[idxt - 1] left_t
import bisect
a, b, q = map(int, input().split())

s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s.append(-100000000000)
s.append(100000000000)
t.append(-100000000000)
t.append(100000000000)
s.sort()
t.sort()

for _ in range(q):
    x = int(input())

    idxs = bisect.bisect_right(s, x)
    idxt = bisect.bisect_right(t, x)
    left_s = s[idxs - 1]
    right_s = s[idxs]
    left_t = t[idxt - 1]
    right_t = t[idxt]

    kouho1 = max(x - left_s, x - left_t)
    kouho2 = max(right_s - x, right_t - x)
    kouho3 = min(x - left_s, right_t - x) * 2 + max(x - left_s, right_t - x)
    kouho4 = min(x - left_t, right_s - x) * 2 + max(x - left_t, right_s - x)
    print(min(kouho1, kouho2, kouho3, kouho4))
