import sys
input = sys.stdin.readline

a, b, q = [int(x) for x in input().split()]
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()

import bisect

for i in x:
    s_idx = bisect.bisect_right(s, i)
    ans = 10 ** 18
    if s_idx == 0:
        s_ = [s[0]]
    elif s_idx >= a:
        s_ = [s[-1]]
    else:
        s_ = [s[s_idx], s[s_idx - 1]]
    for j in s_:
        tmp = abs(i - j)
        t_idx = bisect.bisect_right(t, j)
        if t_idx == 0:
            tmp += abs(j - t[0])
        elif t_idx >= b:
            tmp += abs(j - t[-1])
        else:
            tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1]))
        ans = min(tmp, ans)
    
    t_idx = bisect.bisect_right(t, i)
    if t_idx == 0:
        t_ = [t[0]]
    elif t_idx >= b:
        t_ = [t[-1]]
    else:
        t_ = [t[t_idx], t[t_idx - 1]]
    for j in t_:
        tmp = abs(i - j)
        s_idx = bisect.bisect_right(s, j)
        if s_idx == 0:
            tmp += abs(j - s[0])
        elif s_idx >= a:
            tmp += abs(j - s[-1])
        else:
            tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1]))
        ans = min(tmp, ans)
    print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x a, b, q = [int(x) for x in input().split()] a [int(x) for x in 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)] int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input x = [int(input()) for _ in range(q)] x [int(input()) for _ in range(q)] s.sort() s.sort s sort t.sort() t.sort t sort import bisect bisect for i in x:
    s_idx = bisect.bisect_right(s, i)
    ans = 10 ** 18
    if s_idx == 0:
        s_ = [s[0]]
    elif s_idx >= a:
        s_ = [s[-1]]
    else:
        s_ = [s[s_idx], s[s_idx - 1]]
    for j in s_:
        tmp = abs(i - j)
        t_idx = bisect.bisect_right(t, j)
        if t_idx == 0:
            tmp += abs(j - t[0])
        elif t_idx >= b:
            tmp += abs(j - t[-1])
        else:
            tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1]))
        ans = min(tmp, ans)
    
    t_idx = bisect.bisect_right(t, i)
    if t_idx == 0:
        t_ = [t[0]]
    elif t_idx >= b:
        t_ = [t[-1]]
    else:
        t_ = [t[t_idx], t[t_idx - 1]]
    for j in t_:
        tmp = abs(i - j)
        s_idx = bisect.bisect_right(s, j)
        if s_idx == 0:
            tmp += abs(j - s[0])
        elif s_idx >= a:
            tmp += abs(j - s[-1])
        else:
            tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1]))
        ans = min(tmp, ans)
    print(ans) i x s_idx = bisect.bisect_right(s, i) s_idx bisect.bisect_right(s, i) bisect.bisect_right bisect bisect_right s i ans = 10 ** 18 ans 10 ** 18 10 18 if s_idx == 0:
        s_ = [s[0]]
    elif s_idx >= a:
        s_ = [s[-1]]
    else:
        s_ = [s[s_idx], s[s_idx - 1]]
     s_idx == 0 s_idx 0 s_ = [s[0]] s_ [s[0]] s[0] s 0 elif s_idx >= a:
        s_ = [s[-1]]
     s_idx >= a s_idx a s_ = [s[-1]] s_ [s[-1]] s[-1] s -1 s_ = [s[s_idx], s[s_idx - 1]] s_ [s[s_idx], s[s_idx - 1]] s[s_idx] s s_idx s[s_idx - 1] s s_idx - 1 s_idx 1 for j in s_:
        tmp = abs(i - j)
        t_idx = bisect.bisect_right(t, j)
        if t_idx == 0:
            tmp += abs(j - t[0])
        elif t_idx >= b:
            tmp += abs(j - t[-1])
        else:
            tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1]))
        ans = min(tmp, ans)
    
     j s_ tmp = abs(i - j) tmp abs(i - j) abs i - j i j t_idx = bisect.bisect_right(t, j) t_idx bisect.bisect_right(t, j) bisect.bisect_right bisect bisect_right t j if t_idx == 0:
            tmp += abs(j - t[0])
        elif t_idx >= b:
            tmp += abs(j - t[-1])
        else:
            tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1]))
         t_idx == 0 t_idx 0 tmp += abs(j - t[0]) tmp abs(j - t[0]) abs j - t[0] j t[0] t 0 elif t_idx >= b:
            tmp += abs(j - t[-1])
         t_idx >= b t_idx b tmp += abs(j - t[-1]) tmp abs(j - t[-1]) abs j - t[-1] j t[-1] t -1 tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1])) tmp min(abs(j - t[t_idx]), abs(j - t[t_idx - 1])) min abs(j - t[t_idx]) abs j - t[t_idx] j t[t_idx] t t_idx abs(j - t[t_idx - 1]) abs j - t[t_idx - 1] j t[t_idx - 1] t t_idx - 1 t_idx 1 ans = min(tmp, ans) ans min(tmp, ans) min tmp ans t_idx = bisect.bisect_right(t, i) t_idx bisect.bisect_right(t, i) bisect.bisect_right bisect bisect_right t i if t_idx == 0:
        t_ = [t[0]]
    elif t_idx >= b:
        t_ = [t[-1]]
    else:
        t_ = [t[t_idx], t[t_idx - 1]]
     t_idx == 0 t_idx 0 t_ = [t[0]] t_ [t[0]] t[0] t 0 elif t_idx >= b:
        t_ = [t[-1]]
     t_idx >= b t_idx b t_ = [t[-1]] t_ [t[-1]] t[-1] t -1 t_ = [t[t_idx], t[t_idx - 1]] t_ [t[t_idx], t[t_idx - 1]] t[t_idx] t t_idx t[t_idx - 1] t t_idx - 1 t_idx 1 for j in t_:
        tmp = abs(i - j)
        s_idx = bisect.bisect_right(s, j)
        if s_idx == 0:
            tmp += abs(j - s[0])
        elif s_idx >= a:
            tmp += abs(j - s[-1])
        else:
            tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1]))
        ans = min(tmp, ans)
     j t_ tmp = abs(i - j) tmp abs(i - j) abs i - j i j s_idx = bisect.bisect_right(s, j) s_idx bisect.bisect_right(s, j) bisect.bisect_right bisect bisect_right s j if s_idx == 0:
            tmp += abs(j - s[0])
        elif s_idx >= a:
            tmp += abs(j - s[-1])
        else:
            tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1]))
         s_idx == 0 s_idx 0 tmp += abs(j - s[0]) tmp abs(j - s[0]) abs j - s[0] j s[0] s 0 elif s_idx >= a:
            tmp += abs(j - s[-1])
         s_idx >= a s_idx a tmp += abs(j - s[-1]) tmp abs(j - s[-1]) abs j - s[-1] j s[-1] s -1 tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1])) tmp min(abs(j - s[s_idx]), abs(j - s[s_idx - 1])) min abs(j - s[s_idx]) abs j - s[s_idx] j s[s_idx] s s_idx abs(j - s[s_idx - 1]) abs j - s[s_idx - 1] j s[s_idx - 1] s s_idx - 1 s_idx 1 ans = min(tmp, ans) ans min(tmp, ans) min tmp ans print(ans) print ans 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 t_ = [t[0]] [t[0]] t_ t_ = [t[t_idx], t[t_idx - 1]] [t[t_idx], t[t_idx - 1]] t_ t_idx = bisect.bisect_right(t, j) bisect.bisect_right(t, j) t_idx b, q = [int(x) for x in input().split()] [int(x) for x in input().split()] b tmp += abs(j - t[-1]) abs(j - t[-1]) tmp s_ = [s[0]] [s[0]] s_ tmp += abs(j - t[0]) abs(j - t[0]) tmp a, b, q = [int(x) for x in input().split()] [int(x) for x in input().split()] a x = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] x ans = min(tmp, ans) min(tmp, ans) ans tmp += abs(j - s[-1]) abs(j - s[-1]) tmp tmp = abs(i - j) abs(i - j) tmp q = [int(x) for x in input().split()] [int(x) for x in input().split()] q tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1])) min(abs(j - t[t_idx]), abs(j - t[t_idx - 1])) tmp t_ = [t[-1]] [t[-1]] t_ tmp += abs(j - s[0]) abs(j - s[0]) tmp t_idx = bisect.bisect_right(t, i) bisect.bisect_right(t, i) t_idx ans = 10 ** 18 10 ** 18 ans input = sys.stdin.readline sys.stdin.readline input s_idx = bisect.bisect_right(s, j) bisect.bisect_right(s, j) s_idx tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1])) min(abs(j - s[s_idx]), abs(j - s[s_idx - 1])) tmp tmp = abs(i - j) abs(i - j) tmp s_ = [s[-1]] [s[-1]] s_ s_idx = bisect.bisect_right(s, i) bisect.bisect_right(s, i) s_idx s_ = [s[s_idx], s[s_idx - 1]] [s[s_idx], s[s_idx - 1]] s_ ans = min(tmp, ans) min(tmp, ans) ans
import sys
input = sys.stdin.readline

a, b, q = [int(x) for x in input().split()]
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()

import bisect

for i in x:
    s_idx = bisect.bisect_right(s, i)
    ans = 10 ** 18
    if s_idx == 0:
        s_ = [s[0]]
    elif s_idx >= a:
        s_ = [s[-1]]
    else:
        s_ = [s[s_idx], s[s_idx - 1]]
    for j in s_:
        tmp = abs(i - j)
        t_idx = bisect.bisect_right(t, j)
        if t_idx == 0:
            tmp += abs(j - t[0])
        elif t_idx >= b:
            tmp += abs(j - t[-1])
        else:
            tmp += min(abs(j - t[t_idx]), abs(j - t[t_idx - 1]))
        ans = min(tmp, ans)
    
    t_idx = bisect.bisect_right(t, i)
    if t_idx == 0:
        t_ = [t[0]]
    elif t_idx >= b:
        t_ = [t[-1]]
    else:
        t_ = [t[t_idx], t[t_idx - 1]]
    for j in t_:
        tmp = abs(i - j)
        s_idx = bisect.bisect_right(s, j)
        if s_idx == 0:
            tmp += abs(j - s[0])
        elif s_idx >= a:
            tmp += abs(j - s[-1])
        else:
            tmp += min(abs(j - s[s_idx]), abs(j - s[s_idx - 1]))
        ans = min(tmp, ans)
    print(ans)