from bisect import bisect_right
INFTY = 10**11
A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
S.insert(0,-INFTY)
S.append(INFTY)
T = [int(input()) for _ in range(B)]
T.insert(0,-INFTY)
T.append(INFTY)
for _ in range(Q):
    x = int(input())
    indS = bisect_right(S,x)
    indT = bisect_right(T,x)
    d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1])
    d2 = x-S[indS-1]+abs(S[indS-1]-T[indT])
    d3 = S[indS]-x+abs(S[indS]-T[indT-1])
    d4 = S[indS]-x+abs(S[indS]-T[indT])
    d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1])
    d6 = x-T[indT-1]+abs(T[indT-1]-S[indS])
    d7 = T[indT]-x+abs(T[indT]-S[indS-1])
    d8 = T[indT]-x+abs(T[indT]-S[indS])
    print(min(d1,d2,d3,d4,d5,d6,d7,d8)) from bisect import bisect_right INFTY = 10**11 INFTY 10**11 10 11 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)] S.insert(0,-INFTY) S.insert S insert 0 -INFTY INFTY S.append(INFTY) S.append S append INFTY 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)] T.insert(0,-INFTY) T.insert T insert 0 -INFTY INFTY T.append(INFTY) T.append T append INFTY for _ in range(Q):
    x = int(input())
    indS = bisect_right(S,x)
    indT = bisect_right(T,x)
    d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1])
    d2 = x-S[indS-1]+abs(S[indS-1]-T[indT])
    d3 = S[indS]-x+abs(S[indS]-T[indT-1])
    d4 = S[indS]-x+abs(S[indS]-T[indT])
    d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1])
    d6 = x-T[indT-1]+abs(T[indT-1]-S[indS])
    d7 = T[indT]-x+abs(T[indT]-S[indS-1])
    d8 = T[indT]-x+abs(T[indT]-S[indS])
    print(min(d1,d2,d3,d4,d5,d6,d7,d8)) _ range(Q) range Q x = int(input()) x int(input()) int input() input indS = bisect_right(S,x) indS bisect_right(S,x) bisect_right S x indT = bisect_right(T,x) indT bisect_right(T,x) bisect_right T x d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1]) d1 x-S[indS-1]+abs(S[indS-1]-T[indT-1]) x-S[indS-1] x S[indS-1] S indS-1 indS 1 abs(S[indS-1]-T[indT-1]) abs S[indS-1]-T[indT-1] S[indS-1] S indS-1 indS 1 T[indT-1] T indT-1 indT 1 d2 = x-S[indS-1]+abs(S[indS-1]-T[indT]) d2 x-S[indS-1]+abs(S[indS-1]-T[indT]) x-S[indS-1] x S[indS-1] S indS-1 indS 1 abs(S[indS-1]-T[indT]) abs S[indS-1]-T[indT] S[indS-1] S indS-1 indS 1 T[indT] T indT d3 = S[indS]-x+abs(S[indS]-T[indT-1]) d3 S[indS]-x+abs(S[indS]-T[indT-1]) S[indS]-x S[indS] S indS x abs(S[indS]-T[indT-1]) abs S[indS]-T[indT-1] S[indS] S indS T[indT-1] T indT-1 indT 1 d4 = S[indS]-x+abs(S[indS]-T[indT]) d4 S[indS]-x+abs(S[indS]-T[indT]) S[indS]-x S[indS] S indS x abs(S[indS]-T[indT]) abs S[indS]-T[indT] S[indS] S indS T[indT] T indT d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1]) d5 x-T[indT-1]+abs(T[indT-1]-S[indS-1]) x-T[indT-1] x T[indT-1] T indT-1 indT 1 abs(T[indT-1]-S[indS-1]) abs T[indT-1]-S[indS-1] T[indT-1] T indT-1 indT 1 S[indS-1] S indS-1 indS 1 d6 = x-T[indT-1]+abs(T[indT-1]-S[indS]) d6 x-T[indT-1]+abs(T[indT-1]-S[indS]) x-T[indT-1] x T[indT-1] T indT-1 indT 1 abs(T[indT-1]-S[indS]) abs T[indT-1]-S[indS] T[indT-1] T indT-1 indT 1 S[indS] S indS d7 = T[indT]-x+abs(T[indT]-S[indS-1]) d7 T[indT]-x+abs(T[indT]-S[indS-1]) T[indT]-x T[indT] T indT x abs(T[indT]-S[indS-1]) abs T[indT]-S[indS-1] T[indT] T indT S[indS-1] S indS-1 indS 1 d8 = T[indT]-x+abs(T[indT]-S[indS]) d8 T[indT]-x+abs(T[indT]-S[indS]) T[indT]-x T[indT] T indT x abs(T[indT]-S[indS]) abs T[indT]-S[indS] T[indT] T indT S[indS] S indS print(min(d1,d2,d3,d4,d5,d6,d7,d8)) print min(d1,d2,d3,d4,d5,d6,d7,d8) min d1 d2 d3 d4 d5 d6 d7 d8 indS = bisect_right(S,x) bisect_right(S,x) indS Q = map(int,input().split()) map(int,input().split()) Q d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1]) x-S[indS-1]+abs(S[indS-1]-T[indT-1]) d1 d2 = x-S[indS-1]+abs(S[indS-1]-T[indT]) x-S[indS-1]+abs(S[indS-1]-T[indT]) d2 d3 = S[indS]-x+abs(S[indS]-T[indT-1]) S[indS]-x+abs(S[indS]-T[indT-1]) d3 d6 = x-T[indT-1]+abs(T[indT-1]-S[indS]) x-T[indT-1]+abs(T[indT-1]-S[indS]) d6 INFTY = 10**11 10**11 INFTY indT = bisect_right(T,x) bisect_right(T,x) indT x = int(input()) int(input()) x T = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] T A,B,Q = map(int,input().split()) map(int,input().split()) A S = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] S B,Q = map(int,input().split()) map(int,input().split()) B d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1]) x-T[indT-1]+abs(T[indT-1]-S[indS-1]) d5 d4 = S[indS]-x+abs(S[indS]-T[indT]) S[indS]-x+abs(S[indS]-T[indT]) d4 d7 = T[indT]-x+abs(T[indT]-S[indS-1]) T[indT]-x+abs(T[indT]-S[indS-1]) d7 d8 = T[indT]-x+abs(T[indT]-S[indS]) T[indT]-x+abs(T[indT]-S[indS]) d8
from bisect import bisect_right
INFTY = 10**11
A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
S.insert(0,-INFTY)
S.append(INFTY)
T = [int(input()) for _ in range(B)]
T.insert(0,-INFTY)
T.append(INFTY)
for _ in range(Q):
    x = int(input())
    indS = bisect_right(S,x)
    indT = bisect_right(T,x)
    d1 = x-S[indS-1]+abs(S[indS-1]-T[indT-1])
    d2 = x-S[indS-1]+abs(S[indS-1]-T[indT])
    d3 = S[indS]-x+abs(S[indS]-T[indT-1])
    d4 = S[indS]-x+abs(S[indS]-T[indT])
    d5 = x-T[indT-1]+abs(T[indT-1]-S[indS-1])
    d6 = x-T[indT-1]+abs(T[indT-1]-S[indS])
    d7 = T[indT]-x+abs(T[indT]-S[indS-1])
    d8 = T[indT]-x+abs(T[indT]-S[indS])
    print(min(d1,d2,d3,d4,d5,d6,d7,d8))