import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et)) import bisect bisect import math math a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q s = [-math.inf] s [-math.inf] -math.inf math.inf math inf t = [-math.inf] t [-math.inf] -math.inf math.inf math inf x = [] x [] for _ in range(a):
    s.append(int(input())) _ range(a) range a s.append(int(input())) s.append s append int(input()) int input() input for _ in range(b):
    t.append(int(input())) _ range(b) range b t.append(int(input())) t.append t append int(input()) int input() input for _ in range(q):
    x.append(int(input())) _ range(q) range q x.append(int(input())) x.append x append int(input()) int input() input s.append(math.inf) s.append s append math.inf math inf t.append(math.inf) t.append t append math.inf math inf for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et)) i x ws = abs(s[bisect.bisect(s, i) - 1] - i) ws abs(s[bisect.bisect(s, i) - 1] - i) abs s[bisect.bisect(s, i) - 1] - i s[bisect.bisect(s, i) - 1] s bisect.bisect(s, i) - 1 bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 i if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
     ws != math.inf ws math.inf math inf ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1])) ws min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1])) min abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]) abs t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1] t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] t bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1 bisect.bisect(t, s[bisect.bisect(s, i) - 1]) bisect.bisect bisect bisect t s[bisect.bisect(s, i) - 1] s bisect.bisect(s, i) - 1 bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 1 s[bisect.bisect(s, i) - 1] s bisect.bisect(s, i) - 1 bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]) abs t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1] t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] t bisect.bisect(t, s[bisect.bisect(s, i) - 1]) bisect.bisect bisect bisect t s[bisect.bisect(s, i) - 1] s bisect.bisect(s, i) - 1 bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 s[bisect.bisect(s, i) - 1] s bisect.bisect(s, i) - 1 bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 ws = math.inf ws math.inf math inf es = abs(s[bisect.bisect(s, i)] - i) es abs(s[bisect.bisect(s, i)] - i) abs s[bisect.bisect(s, i)] - i s[bisect.bisect(s, i)] s bisect.bisect(s, i) bisect.bisect bisect bisect s i i if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
     es != math.inf es math.inf math inf es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)])) es min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)])) min abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]) abs t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)] t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] t bisect.bisect(t, s[bisect.bisect(s, i)]) -1 bisect.bisect(t, s[bisect.bisect(s, i)]) bisect.bisect bisect bisect t s[bisect.bisect(s, i)] s bisect.bisect(s, i) bisect.bisect bisect bisect s i 1 s[bisect.bisect(s, i)] s bisect.bisect(s, i) bisect.bisect bisect bisect s i abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]) abs t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)] t[bisect.bisect(t, s[bisect.bisect(s, i)])] t bisect.bisect(t, s[bisect.bisect(s, i)]) bisect.bisect bisect bisect t s[bisect.bisect(s, i)] s bisect.bisect(s, i) bisect.bisect bisect bisect s i s[bisect.bisect(s, i)] s bisect.bisect(s, i) bisect.bisect bisect bisect s i es = math.inf es math.inf math inf wt = abs(t[bisect.bisect(t, i) - 1] - i) wt abs(t[bisect.bisect(t, i) - 1] - i) abs t[bisect.bisect(t, i) - 1] - i t[bisect.bisect(t, i) - 1] t bisect.bisect(t, i) - 1 bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 i if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
     wt != math.inf wt math.inf math inf wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1])) wt min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1])) min abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]) abs s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1] s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] s bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1 bisect.bisect(s, t[bisect.bisect(t, i) - 1]) bisect.bisect bisect bisect s t[bisect.bisect(t, i) - 1] t bisect.bisect(t, i) - 1 bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 1 t[bisect.bisect(t, i) - 1] t bisect.bisect(t, i) - 1 bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]) abs s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1] s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] s bisect.bisect(s, t[bisect.bisect(t, i) - 1]) bisect.bisect bisect bisect s t[bisect.bisect(t, i) - 1] t bisect.bisect(t, i) - 1 bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 t[bisect.bisect(t, i) - 1] t bisect.bisect(t, i) - 1 bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 wt = math.inf wt math.inf math inf et = abs(t[bisect.bisect(t, i)] - i) et abs(t[bisect.bisect(t, i)] - i) abs t[bisect.bisect(t, i)] - i t[bisect.bisect(t, i)] t bisect.bisect(t, i) bisect.bisect bisect bisect t i i if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
     et != math.inf et math.inf math inf et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)])) et min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)])) min abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]) abs s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)] s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] s bisect.bisect(s, t[bisect.bisect(t, i)])-1 bisect.bisect(s, t[bisect.bisect(t, i)]) bisect.bisect bisect bisect s t[bisect.bisect(t, i)] t bisect.bisect(t, i) bisect.bisect bisect bisect t i 1 t[bisect.bisect(t, i)] t bisect.bisect(t, i) bisect.bisect bisect bisect t i abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]) abs s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)] s[bisect.bisect(s, t[bisect.bisect(t, i)])] s bisect.bisect(s, t[bisect.bisect(t, i)]) bisect.bisect bisect bisect s t[bisect.bisect(t, i)] t bisect.bisect(t, i) bisect.bisect bisect bisect t i t[bisect.bisect(t, i)] t bisect.bisect(t, i) bisect.bisect bisect bisect t i et = math.inf et math.inf math inf print(min(ws, es, wt, et)) print min(ws, es, wt, et) min ws es wt et t = [-math.inf] [-math.inf] t et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)])) min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)])) et q = map(int, input().split()) map(int, input().split()) q es = math.inf math.inf es wt = abs(t[bisect.bisect(t, i) - 1] - i) abs(t[bisect.bisect(t, i) - 1] - i) wt a, b, q = map(int, input().split()) map(int, input().split()) a x = [] [] x b, q = map(int, input().split()) map(int, input().split()) b s = [-math.inf] [-math.inf] s et = math.inf math.inf et es = abs(s[bisect.bisect(s, i)] - i) abs(s[bisect.bisect(s, i)] - i) es ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1])) min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1])) ws wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1])) min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1])) wt es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)])) min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)])) es wt = math.inf math.inf wt ws = math.inf math.inf ws ws = abs(s[bisect.bisect(s, i) - 1] - i) abs(s[bisect.bisect(s, i) - 1] - i) ws et = abs(t[bisect.bisect(t, i)] - i) abs(t[bisect.bisect(t, i)] - i) et
import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et))