import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

A,B,Q = LI()
s = [NI() for _ in range(A)]
t = [NI() for _ in range(B)]
x = [NI() for _ in range(Q)]

s.sort()
t.sort()
s = [-2*INF,-INF] + s + [INF,2*INF]
t = [-2*INF,-INF] + t + [INF,2*INF]

for p in x:
    ans = INF

    si = bisect.bisect_left(s,p)
    s1 = s[si-1]
    s2 = s[si]

    ti1 = bisect.bisect_left(t,s1)
    t11 = t[ti1-1]
    ans = min(ans,p - t11)
    t12 = t[ti1]
    ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p))

    ti2 = bisect.bisect_left(t,s2)
    t21 = t[ti2-1]
    ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p))
    t22 = t[ti2]
    ans = min(ans, t22 - p)

    ti = bisect.bisect_left(t, p)
    t1 = t[ti - 1]
    t2 = t[ti]

    si1 = bisect.bisect_left(s, t1)
    s11 = s[si1 - 1]
    ans = min(ans, p - s11)
    s12 = s[si1]
    ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p))

    si2 = bisect.bisect_left(s, t2)
    s21 = s[si2 - 1]
    ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p))
    s22 = s[si2]
    ans = min(ans, s22 - p)

    print (ans)
 import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**18 INF 10**18 10 18 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] int(x)-1 for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x)-1 int(x) int x 1 _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()] _LI lambda : [int(x)-1 for x in sys.stdin.readline().split()] [int(x)-1 for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline A,B,Q = LI() A LI() LI B Q NI() for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) NI() NI s = [NI() for _ in range(A)] s [NI() for _ in range(A)] NI() for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) NI() NI t = [NI() for _ in range(B)] t [NI() for _ in range(B)] NI() for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) NI() NI x = [NI() for _ in range(Q)] x [NI() for _ in range(Q)] s.sort() s.sort s sort t.sort() t.sort t sort s = [-2*INF,-INF] + s + [INF,2*INF] s [-2*INF,-INF] + s + [INF,2*INF] [-2*INF,-INF] + s [-2*INF,-INF] -2*INF -2 INF -INF INF s [INF,2*INF] INF 2*INF 2 INF t = [-2*INF,-INF] + t + [INF,2*INF] t [-2*INF,-INF] + t + [INF,2*INF] [-2*INF,-INF] + t [-2*INF,-INF] -2*INF -2 INF -INF INF t [INF,2*INF] INF 2*INF 2 INF for p in x:
    ans = INF

    si = bisect.bisect_left(s,p)
    s1 = s[si-1]
    s2 = s[si]

    ti1 = bisect.bisect_left(t,s1)
    t11 = t[ti1-1]
    ans = min(ans,p - t11)
    t12 = t[ti1]
    ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p))

    ti2 = bisect.bisect_left(t,s2)
    t21 = t[ti2-1]
    ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p))
    t22 = t[ti2]
    ans = min(ans, t22 - p)

    ti = bisect.bisect_left(t, p)
    t1 = t[ti - 1]
    t2 = t[ti]

    si1 = bisect.bisect_left(s, t1)
    s11 = s[si1 - 1]
    ans = min(ans, p - s11)
    s12 = s[si1]
    ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p))

    si2 = bisect.bisect_left(s, t2)
    s21 = s[si2 - 1]
    ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p))
    s22 = s[si2]
    ans = min(ans, s22 - p)

    print (ans) p x ans = INF ans INF si = bisect.bisect_left(s,p) si bisect.bisect_left(s,p) bisect.bisect_left bisect bisect_left s p s1 = s[si-1] s1 s[si-1] s si-1 si 1 s2 = s[si] s2 s[si] s si ti1 = bisect.bisect_left(t,s1) ti1 bisect.bisect_left(t,s1) bisect.bisect_left bisect bisect_left t s1 t11 = t[ti1-1] t11 t[ti1-1] t ti1-1 ti1 1 ans = min(ans,p - t11) ans min(ans,p - t11) min ans p - t11 p t11 t12 = t[ti1] t12 t[ti1] t ti1 ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p)) ans min(ans,(p - s1) + (t12 - s1)  * (t12 > p)) min ans (p - s1) + (t12 - s1)  * (t12 > p) p - s1 p s1 (t12 - s1)  * (t12 > p) t12 - s1 t12 s1 t12 > p t12 p ti2 = bisect.bisect_left(t,s2) ti2 bisect.bisect_left(t,s2) bisect.bisect_left bisect bisect_left t s2 t21 = t[ti2-1] t21 t[ti2-1] t ti2-1 ti2 1 ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p)) ans min(ans,(s2 - p) + (s2 - t21) * (t21 < p)) min ans (s2 - p) + (s2 - t21) * (t21 < p) s2 - p s2 p (s2 - t21) * (t21 < p) s2 - t21 s2 t21 t21 < p t21 p t22 = t[ti2] t22 t[ti2] t ti2 ans = min(ans, t22 - p) ans min(ans, t22 - p) min ans t22 - p t22 p ti = bisect.bisect_left(t, p) ti bisect.bisect_left(t, p) bisect.bisect_left bisect bisect_left t p t1 = t[ti - 1] t1 t[ti - 1] t ti - 1 ti 1 t2 = t[ti] t2 t[ti] t ti si1 = bisect.bisect_left(s, t1) si1 bisect.bisect_left(s, t1) bisect.bisect_left bisect bisect_left s t1 s11 = s[si1 - 1] s11 s[si1 - 1] s si1 - 1 si1 1 ans = min(ans, p - s11) ans min(ans, p - s11) min ans p - s11 p s11 s12 = s[si1] s12 s[si1] s si1 ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p)) ans min(ans, (p - t1) + (s12 - t1) * (s12 > p)) min ans (p - t1) + (s12 - t1) * (s12 > p) p - t1 p t1 (s12 - t1) * (s12 > p) s12 - t1 s12 t1 s12 > p s12 p si2 = bisect.bisect_left(s, t2) si2 bisect.bisect_left(s, t2) bisect.bisect_left bisect bisect_left s t2 s21 = s[si2 - 1] s21 s[si2 - 1] s si2 - 1 si2 1 ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p)) ans min(ans, (t2 - p) + (t2 - s21) * (s21 < p)) min ans (t2 - p) + (t2 - s21) * (s21 < p) t2 - p t2 p (t2 - s21) * (s21 < p) t2 - s21 t2 s21 s21 < p s21 p s22 = s[si2] s22 s[si2] s si2 ans = min(ans, s22 - p) ans min(ans, s22 - p) min ans s22 - p s22 p print (ans) print ans _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()] lambda : [int(x)-1 for x in sys.stdin.readline().split()] _LI NI = lambda : int(sys.stdin.readline()) lambda : int(sys.stdin.readline()) NI s1 = s[si-1] s[si-1] s1 t11 = t[ti1-1] t[ti1-1] t11 si = bisect.bisect_left(s,p) bisect.bisect_left(s,p) si s21 = s[si2 - 1] s[si2 - 1] s21 s2 = s[si] s[si] s2 s12 = s[si1] s[si1] s12 ti = bisect.bisect_left(t, p) bisect.bisect_left(t, p) ti MOD = 10**9 + 7 10**9 + 7 MOD ti1 = bisect.bisect_left(t,s1) bisect.bisect_left(t,s1) ti1 ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p)) min(ans, (t2 - p) + (t2 - s21) * (s21 < p)) ans x = [NI() for _ in range(Q)] [NI() for _ in range(Q)] x ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p)) min(ans,(p - s1) + (t12 - s1)  * (t12 > p)) ans ans = min(ans, s22 - p) min(ans, s22 - p) ans t = [-2*INF,-INF] + t + [INF,2*INF] [-2*INF,-INF] + t + [INF,2*INF] t LI = lambda : [int(x) for x in sys.stdin.readline().split()] lambda : [int(x) for x in sys.stdin.readline().split()] LI si1 = bisect.bisect_left(s, t1) bisect.bisect_left(s, t1) si1 Q = LI() LI() Q t21 = t[ti2-1] t[ti2-1] t21 ans = min(ans, p - s11) min(ans, p - s11) ans ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p)) min(ans, (p - t1) + (s12 - t1) * (s12 > p)) ans si2 = bisect.bisect_left(s, t2) bisect.bisect_left(s, t2) si2 ans = min(ans, t22 - p) min(ans, t22 - p) ans t2 = t[ti] t[ti] t2 t = [NI() for _ in range(B)] [NI() for _ in range(B)] t s22 = s[si2] s[si2] s22 s = [-2*INF,-INF] + s + [INF,2*INF] [-2*INF,-INF] + s + [INF,2*INF] s ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p)) min(ans,(s2 - p) + (s2 - t21) * (t21 < p)) ans ans = INF INF ans ans = min(ans,p - t11) min(ans,p - t11) ans INF = 10**18 10**18 INF B,Q = LI() LI() B A,B,Q = LI() LI() A ti2 = bisect.bisect_left(t,s2) bisect.bisect_left(t,s2) ti2 t12 = t[ti1] t[ti1] t12 s11 = s[si1 - 1] s[si1 - 1] s11 t1 = t[ti - 1] t[ti - 1] t1 s = [NI() for _ in range(A)] [NI() for _ in range(A)] s t22 = t[ti2] t[ti2] t22
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

A,B,Q = LI()
s = [NI() for _ in range(A)]
t = [NI() for _ in range(B)]
x = [NI() for _ in range(Q)]

s.sort()
t.sort()
s = [-2*INF,-INF] + s + [INF,2*INF]
t = [-2*INF,-INF] + t + [INF,2*INF]

for p in x:
    ans = INF

    si = bisect.bisect_left(s,p)
    s1 = s[si-1]
    s2 = s[si]

    ti1 = bisect.bisect_left(t,s1)
    t11 = t[ti1-1]
    ans = min(ans,p - t11)
    t12 = t[ti1]
    ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p))

    ti2 = bisect.bisect_left(t,s2)
    t21 = t[ti2-1]
    ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p))
    t22 = t[ti2]
    ans = min(ans, t22 - p)

    ti = bisect.bisect_left(t, p)
    t1 = t[ti - 1]
    t2 = t[ti]

    si1 = bisect.bisect_left(s, t1)
    s11 = s[si1 - 1]
    ans = min(ans, p - s11)
    s12 = s[si1]
    ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p))

    si2 = bisect.bisect_left(s, t2)
    s21 = s[si2 - 1]
    ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p))
    s22 = s[si2]
    ans = min(ans, s22 - p)

    print (ans)

