# -*- coding: utf-8 -*-

A,B,Q = list(map(int, input().rstrip().split()))
s_list = [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11]
t_list = [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11]
x_list = [int(input().strip()) for _ in range(Q)]
#-----

# x_dic={ x : [a1,a2,b1,b2]}
#    距離xに対して、最も近い神社・寺のindexを保存
#      a1(xより西の最寄りの神社)、a2(xより東の最寄りの神社)
#      b1(xより西の最寄りの寺)、  b2(xより東の最寄りの寺)
x_dic={}

x_sort = sorted(x_list)

i_x=0
for i in range(len(s_list) - 1):
    
    while s_list[i] <= x_sort[i_x] <= s_list[i+1]:
        x_dic[x_sort[i_x]] = [i,(i+1)]
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break
    

i_x=0
for i in range(len(t_list) - 1):
    
    while t_list[i] <= x_sort[i_x] <= t_list[i+1]:
        x_dic[x_sort[i_x]].extend( [i,(i+1)] )
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break


for x in x_list:
    dist_min=10**11
    
    for s in x_dic[x][0:2]:
        for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
    print(dist_min) A,B,Q = list(map(int, input().rstrip().split())) A list(map(int, input().rstrip().split())) list map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split B Q int(input().strip()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input().strip()) int input().strip() ().strip () input strip s_list = [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11] s_list [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11] [-10**11] + [int(input().strip()) for _ in range(A)] [-10**11] -10**11 -10 11 [int(input().strip()) for _ in range(A)] [10**11] 10**11 10 11 int(input().strip()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input().strip()) int input().strip() ().strip () input strip t_list = [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11] t_list [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11] [-10**11] + [int(input().strip()) for _ in range(B)] [-10**11] -10**11 -10 11 [int(input().strip()) for _ in range(B)] [10**11] 10**11 10 11 int(input().strip()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input().strip()) int input().strip() ().strip () input strip x_list = [int(input().strip()) for _ in range(Q)] x_list [int(input().strip()) for _ in range(Q)] x_dic={} x_dic {} x_sort = sorted(x_list) x_sort sorted(x_list) sorted x_list i_x=0 i_x 0 for i in range(len(s_list) - 1):
    
    while s_list[i] <= x_sort[i_x] <= s_list[i+1]:
        x_dic[x_sort[i_x]] = [i,(i+1)]
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break
     i range(len(s_list) - 1) range len(s_list) - 1 len(s_list) len s_list 1 while s_list[i] <= x_sort[i_x] <= s_list[i+1]:
        x_dic[x_sort[i_x]] = [i,(i+1)]
        i_x += 1
        
        if i_x > len(x_sort)-1: break
     s_list[i] <= x_sort[i_x] <= s_list[i+1] s_list[i] <= x_sort[i_x] s_list[i] s_list i x_sort[i_x] x_sort i_x s_list[i+1] s_list i+1 i 1 x_dic[x_sort[i_x]] = [i,(i+1)] x_dic[x_sort[i_x]] x_dic x_sort[i_x] x_sort i_x [i,(i+1)] i i+1 i 1 i_x += 1 i_x 1 if i_x > len(x_sort)-1: break
     i_x > len(x_sort)-1 i_x len(x_sort)-1 len(x_sort) len x_sort 1 if i_x > len(x_sort)-1: break
     i_x > len(x_sort)-1 i_x len(x_sort)-1 len(x_sort) len x_sort 1 i_x=0 i_x 0 for i in range(len(t_list) - 1):
    
    while t_list[i] <= x_sort[i_x] <= t_list[i+1]:
        x_dic[x_sort[i_x]].extend( [i,(i+1)] )
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break i range(len(t_list) - 1) range len(t_list) - 1 len(t_list) len t_list 1 while t_list[i] <= x_sort[i_x] <= t_list[i+1]:
        x_dic[x_sort[i_x]].extend( [i,(i+1)] )
        i_x += 1
        
        if i_x > len(x_sort)-1: break
     t_list[i] <= x_sort[i_x] <= t_list[i+1] t_list[i] <= x_sort[i_x] t_list[i] t_list i x_sort[i_x] x_sort i_x t_list[i+1] t_list i+1 i 1 x_dic[x_sort[i_x]].extend( [i,(i+1)] ) [x_sort[i_x]].extend [x_sort[i_x]] x_dic x_sort[i_x] x_sort i_x extend [i,(i+1)] i i+1 i 1 i_x += 1 i_x 1 if i_x > len(x_sort)-1: break
     i_x > len(x_sort)-1 i_x len(x_sort)-1 len(x_sort) len x_sort 1 if i_x > len(x_sort)-1: b i_x > len(x_sort)-1 i_x len(x_sort)-1 len(x_sort) len x_sort 1 for x in x_list:
    dist_min=10**11
    
    for s in x_dic[x][0:2]:
        for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
    print(dist_min) x x_list dist_min=10**11 dist_min 10**11 10 11 for s in x_dic[x][0:2]:
        for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
     s x_dic[x][0:2] [x] x_dic x 0:2 0 2 for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
     t x_dic[x][2:4] [x] x_dic x 2:4 2 4 diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s]) diff1 abs(s_list[s] - x) + abs(t_list[t] - s_list[s]) abs(s_list[s] - x) abs s_list[s] - x s_list[s] s_list s x abs(t_list[t] - s_list[s]) abs t_list[t] - s_list[s] t_list[t] t_list t s_list[s] s_list s diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t]) diff2 abs(t_list[t] - x) + abs(s_list[s] - t_list[t]) abs(t_list[t] - x) abs t_list[t] - x t_list[t] t_list t x abs(s_list[s] - t_list[t]) abs s_list[s] - t_list[t] s_list[s] s_list s t_list[t] t_list t dist_min = min(dist_min, diff1, diff2) dist_min min(dist_min, diff1, diff2) min dist_min diff1 diff2 print(dist_min) print dist_min dist_min = min(dist_min, diff1, diff2) min(dist_min, diff1, diff2) dist_min B,Q = list(map(int, input().rstrip().split())) list(map(int, input().rstrip().split())) B x_sort = sorted(x_list) sorted(x_list) x_sort x_dic={} {} x_dic t_list = [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11] [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11] t_list A,B,Q = list(map(int, input().rstrip().split())) list(map(int, input().rstrip().split())) A s_list = [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11] [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11] s_list i_x=0 0 i_x i_x += 1 1 i_x diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s]) abs(s_list[s] - x) + abs(t_list[t] - s_list[s]) diff1 dist_min=10**11 10**11 dist_min x_list = [int(input().strip()) for _ in range(Q)] [int(input().strip()) for _ in range(Q)] x_list Q = list(map(int, input().rstrip().split())) list(map(int, input().rstrip().split())) Q diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t]) abs(t_list[t] - x) + abs(s_list[s] - t_list[t]) diff2 i_x=0 0 i_x i_x += 1 1 i_x
# -*- coding: utf-8 -*-

A,B,Q = list(map(int, input().rstrip().split()))
s_list = [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11]
t_list = [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11]
x_list = [int(input().strip()) for _ in range(Q)]
#-----

# x_dic={ x : [a1,a2,b1,b2]}
#    距離xに対して、最も近い神社・寺のindexを保存
#      a1(xより西の最寄りの神社)、a2(xより東の最寄りの神社)
#      b1(xより西の最寄りの寺)、  b2(xより東の最寄りの寺)
x_dic={}

x_sort = sorted(x_list)

i_x=0
for i in range(len(s_list) - 1):
    
    while s_list[i] <= x_sort[i_x] <= s_list[i+1]:
        x_dic[x_sort[i_x]] = [i,(i+1)]
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break
    

i_x=0
for i in range(len(t_list) - 1):
    
    while t_list[i] <= x_sort[i_x] <= t_list[i+1]:
        x_dic[x_sort[i_x]].extend( [i,(i+1)] )
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break


for x in x_list:
    dist_min=10**11
    
    for s in x_dic[x][0:2]:
        for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
    print(dist_min)
