from bisect import bisect_left as bl
def dist(p1,p2): return abs(p1-p2)
INF = 10**18
a,b,q = map(int,input().split())
S = [-INF]+[int(input()) for _ in range(a)]+[INF]
T = [-INF]+[int(input()) for _ in range(b)]+[INF]
X = [int(input()) for _ in range(q)]

for i in range(q):
    ans = INF
    s = bl(S,X[i])
    t = bl(T,X[i])
    p = ((s,t),(s-1,t-1))
    for ps,pt in p:
        if dist(X[i],S[ps]) < dist(X[i],T[pt]):
            pt = bl(T,S[ps])
            ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])))
        else:
            ps = bl(S,T[pt])
            ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])))
    print(ans) from bisect import bisect_left as bl def dist(p1,p2): return abs(p1-p2) dist p1 p1 p2 p2 INF = 10**18 INF 10**18 10 18 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 = [-INF]+[int(input()) for _ in range(a)]+[INF] S [-INF]+[int(input()) for _ in range(a)]+[INF] [-INF]+[int(input()) for _ in range(a)] [-INF] -INF INF [int(input()) for _ in range(a)] [INF] INF int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input T = [-INF]+[int(input()) for _ in range(b)]+[INF] T [-INF]+[int(input()) for _ in range(b)]+[INF] [-INF]+[int(input()) for _ in range(b)] [-INF] -INF INF [int(input()) for _ in range(b)] [INF] INF 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)] for i in range(q):
    ans = INF
    s = bl(S,X[i])
    t = bl(T,X[i])
    p = ((s,t),(s-1,t-1))
    for ps,pt in p:
        if dist(X[i],S[ps]) < dist(X[i],T[pt]):
            pt = bl(T,S[ps])
            ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])))
        else:
            ps = bl(S,T[pt])
            ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])))
    print(ans) i range(q) range q ans = INF ans INF s = bl(S,X[i]) s bl(S,X[i]) bl S X[i] X i t = bl(T,X[i]) t bl(T,X[i]) bl T X[i] X i p = ((s,t),(s-1,t-1)) p ((s,t),(s-1,t-1)) (s,t) s t (s-1,t-1) s-1 s 1 t-1 t 1 for ps,pt in p:
        if dist(X[i],S[ps]) < dist(X[i],T[pt]):
            pt = bl(T,S[ps])
            ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])))
        else:
            ps = bl(S,T[pt])
            ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])))
     ps pt p if dist(X[i],S[ps]) < dist(X[i],T[pt]):
            pt = bl(T,S[ps])
            ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])))
        else:
            ps = bl(S,T[pt])
            ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])))
     dist(X[i],S[ps]) < dist(X[i],T[pt]) dist(X[i],S[ps]) dist X[i] X i S[ps] S ps dist(X[i],T[pt]) dist X[i] X i T[pt] T pt pt = bl(T,S[ps]) pt bl(T,S[ps]) bl T S[ps] S ps ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1]))) ans min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1]))) min ans dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])) dist(X[i],S[ps]) dist X[i] X i S[ps] S ps min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])) min dist(S[ps],T[pt]) dist S[ps] S ps T[pt] T pt dist(S[ps],T[pt-1]) dist S[ps] S ps T[pt-1] T pt-1 pt 1 ps = bl(S,T[pt]) ps bl(S,T[pt]) bl S T[pt] T pt ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1]))) ans min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1]))) min ans dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])) dist(X[i],T[pt]) dist X[i] X i T[pt] T pt min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])) min dist(T[pt],S[ps]) dist T[pt] T pt S[ps] S ps dist(T[pt],S[ps-1]) dist T[pt] T pt S[ps-1] S ps-1 ps 1 print(ans) print ans S = [-INF]+[int(input()) for _ in range(a)]+[INF] [-INF]+[int(input()) for _ in range(a)]+[INF] S ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1]))) min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1]))) ans b,q = map(int,input().split()) map(int,input().split()) b q = map(int,input().split()) map(int,input().split()) q T = [-INF]+[int(input()) for _ in range(b)]+[INF] [-INF]+[int(input()) for _ in range(b)]+[INF] T a,b,q = map(int,input().split()) map(int,input().split()) a s = bl(S,X[i]) bl(S,X[i]) s t = bl(T,X[i]) bl(T,X[i]) t p = ((s,t),(s-1,t-1)) ((s,t),(s-1,t-1)) p ans = INF INF ans ps = bl(S,T[pt]) bl(S,T[pt]) ps ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1]))) min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1]))) ans def dist(p1,p2): return abs(p1-p2) def dist(p1,p2): return abs(p1-p2) dist INF = 10**18 10**18 INF X = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] X pt = bl(T,S[ps]) bl(T,S[ps]) pt
from bisect import bisect_left as bl
def dist(p1,p2): return abs(p1-p2)
INF = 10**18
a,b,q = map(int,input().split())
S = [-INF]+[int(input()) for _ in range(a)]+[INF]
T = [-INF]+[int(input()) for _ in range(b)]+[INF]
X = [int(input()) for _ in range(q)]

for i in range(q):
    ans = INF
    s = bl(S,X[i])
    t = bl(T,X[i])
    p = ((s,t),(s-1,t-1))
    for ps,pt in p:
        if dist(X[i],S[ps]) < dist(X[i],T[pt]):
            pt = bl(T,S[ps])
            ans = min(ans , dist(X[i],S[ps])+min(dist(S[ps],T[pt]),dist(S[ps],T[pt-1])))
        else:
            ps = bl(S,T[pt])
            ans = min(ans , dist(X[i],T[pt])+min(dist(T[pt],S[ps]),dist(T[pt],S[ps-1])))
    print(ans)