import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, Q = mapint()
Ss = [-10**20]+[int(input()) for _ in range(A)]+[10**20]
Ts = [-10**20]+[int(input()) for _ in range(B)]+[10**20]
Ss.sort()
Ts.sort()
from bisect import bisect_left

for _ in range(Q):
    x = int(input())
    xs = bisect_left(Ss, x)
    xt = bisect_left(Ts, x)

    rr = max(Ss[xs]-x, Ts[xt]-x)
    ll = max(x-Ss[xs-1], x-Ts[xt-1])
    lr = min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs]))
    rl = min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2)
    print(min(rr, ll, rl, lr)) import sys sys def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) mapint sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 A, B, Q = mapint() A mapint() mapint 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 Ss = [-10**20]+[int(input()) for _ in range(A)]+[10**20] Ss [-10**20]+[int(input()) for _ in range(A)]+[10**20] [-10**20]+[int(input()) for _ in range(A)] [-10**20] -10**20 -10 20 [int(input()) for _ in range(A)] [10**20] 10**20 10 20 int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input Ts = [-10**20]+[int(input()) for _ in range(B)]+[10**20] Ts [-10**20]+[int(input()) for _ in range(B)]+[10**20] [-10**20]+[int(input()) for _ in range(B)] [-10**20] -10**20 -10 20 [int(input()) for _ in range(B)] [10**20] 10**20 10 20 Ss.sort() Ss.sort Ss sort Ts.sort() Ts.sort Ts sort from bisect import bisect_left for _ in range(Q):
    x = int(input())
    xs = bisect_left(Ss, x)
    xt = bisect_left(Ts, x)

    rr = max(Ss[xs]-x, Ts[xt]-x)
    ll = max(x-Ss[xs-1], x-Ts[xt-1])
    lr = min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs]))
    rl = min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2)
    print(min(rr, ll, rl, lr)) _ range(Q) range Q x = int(input()) x int(input()) int input() input xs = bisect_left(Ss, x) xs bisect_left(Ss, x) bisect_left Ss x xt = bisect_left(Ts, x) xt bisect_left(Ts, x) bisect_left Ts x rr = max(Ss[xs]-x, Ts[xt]-x) rr max(Ss[xs]-x, Ts[xt]-x) max Ss[xs]-x Ss[xs] Ss xs x Ts[xt]-x Ts[xt] Ts xt x ll = max(x-Ss[xs-1], x-Ts[xt-1]) ll max(x-Ss[xs-1], x-Ts[xt-1]) max x-Ss[xs-1] x Ss[xs-1] Ss xs-1 xs 1 x-Ts[xt-1] x Ts[xt-1] Ts xt-1 xt 1 lr = min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs])) lr min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs])) min abs(x-Ss[xs-1])*2+abs(x-Ts[xt]) abs(x-Ss[xs-1])*2 abs(x-Ss[xs-1]) abs x-Ss[xs-1] x Ss[xs-1] Ss xs-1 xs 1 2 abs(x-Ts[xt]) abs x-Ts[xt] x Ts[xt] Ts xt abs(x-Ts[xt-1])*2+abs(x-Ss[xs]) abs(x-Ts[xt-1])*2 abs(x-Ts[xt-1]) abs x-Ts[xt-1] x Ts[xt-1] Ts xt-1 xt 1 2 abs(x-Ss[xs]) abs x-Ss[xs] x Ss[xs] Ss xs rl = min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2) rl min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2) min abs(x-Ss[xs-1])+abs(x-Ts[xt])*2 abs(x-Ss[xs-1]) abs x-Ss[xs-1] x Ss[xs-1] Ss xs-1 xs 1 abs(x-Ts[xt])*2 abs(x-Ts[xt]) abs x-Ts[xt] x Ts[xt] Ts xt 2 abs(x-Ts[xt-1])+abs(x-Ss[xs])*2 abs(x-Ts[xt-1]) abs x-Ts[xt-1] x Ts[xt-1] Ts xt-1 xt 1 abs(x-Ss[xs])*2 abs(x-Ss[xs]) abs x-Ss[xs] x Ss[xs] Ss xs 2 print(min(rr, ll, rl, lr)) print min(rr, ll, rl, lr) min rr ll rl lr rr = max(Ss[xs]-x, Ts[xt]-x) max(Ss[xs]-x, Ts[xt]-x) rr xs = bisect_left(Ss, x) bisect_left(Ss, x) xs rl = min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2) min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2) rl xt = bisect_left(Ts, x) bisect_left(Ts, x) xt A, B, Q = mapint() mapint() A x = int(input()) int(input()) x Q = mapint() mapint() Q Ss = [-10**20]+[int(input()) for _ in range(A)]+[10**20] [-10**20]+[int(input()) for _ in range(A)]+[10**20] Ss lr = min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs])) min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs])) lr ll = max(x-Ss[xs-1], x-Ts[xt-1]) max(x-Ss[xs-1], x-Ts[xt-1]) ll def mapint(): return map(int, input().split()) def mapint(): return map(int, input().split()) mapint Ts = [-10**20]+[int(input()) for _ in range(B)]+[10**20] [-10**20]+[int(input()) for _ in range(B)]+[10**20] Ts def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input B, Q = mapint() mapint() B
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, Q = mapint()
Ss = [-10**20]+[int(input()) for _ in range(A)]+[10**20]
Ts = [-10**20]+[int(input()) for _ in range(B)]+[10**20]
Ss.sort()
Ts.sort()
from bisect import bisect_left

for _ in range(Q):
    x = int(input())
    xs = bisect_left(Ss, x)
    xt = bisect_left(Ts, x)

    rr = max(Ss[xs]-x, Ts[xt]-x)
    ll = max(x-Ss[xs-1], x-Ts[xt-1])
    lr = min(abs(x-Ss[xs-1])*2+abs(x-Ts[xt]), abs(x-Ts[xt-1])*2+abs(x-Ss[xs]))
    rl = min(abs(x-Ss[xs-1])+abs(x-Ts[xt])*2, abs(x-Ts[xt-1])+abs(x-Ss[xs])*2)
    print(min(rr, ll, rl, lr))