from bisect import *
a, b, q = map(int,input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
inf = 10 ** 18
s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

for i in range(q):
    x = int(input())
    s_ind = bisect_left(s, x)
    t_ind = bisect_left(t, x)
    
    res = inf
    for cand_s in [s[s_ind - 1], s[s_ind]]:
        for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
    print(res) from bisect import * 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)] 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)] inf = 10 ** 18 inf 10 ** 18 10 18 s = [-inf] + s + [inf] s [-inf] + s + [inf] [-inf] + s [-inf] -inf inf s [inf] inf t = [-inf] + t + [inf] t [-inf] + t + [inf] [-inf] + t [-inf] -inf inf t [inf] inf for i in range(q):
    x = int(input())
    s_ind = bisect_left(s, x)
    t_ind = bisect_left(t, x)
    
    res = inf
    for cand_s in [s[s_ind - 1], s[s_ind]]:
        for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
    print(res) i range(q) range q x = int(input()) x int(input()) int input() input s_ind = bisect_left(s, x) s_ind bisect_left(s, x) bisect_left s x t_ind = bisect_left(t, x) t_ind bisect_left(t, x) bisect_left t x res = inf res inf for cand_s in [s[s_ind - 1], s[s_ind]]:
        for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
     cand_s [s[s_ind - 1], s[s_ind]] s[s_ind - 1] s s_ind - 1 s_ind 1 s[s_ind] s s_ind for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
     cand_t [t[t_ind - 1], t[t_ind]] t[t_ind - 1] t t_ind - 1 t_ind 1 t[t_ind] t t_ind st = abs(cand_s - cand_t) st abs(cand_s - cand_t) abs cand_s - cand_t cand_s cand_t dx = min(abs(cand_s - x), abs(cand_t - x)) dx min(abs(cand_s - x), abs(cand_t - x)) min abs(cand_s - x) abs cand_s - x cand_s x abs(cand_t - x) abs cand_t - x cand_t x res = min(res, st + dx) res min(res, st + dx) min res st + dx st dx print(res) print res s_ind = bisect_left(s, x) bisect_left(s, x) s_ind inf = 10 ** 18 10 ** 18 inf t = [int(input()) for _ in range(b)] [int(input()) for _ in range(b)] t res = min(res, st + dx) min(res, st + dx) res b, q = map(int,input().split()) map(int,input().split()) b t_ind = bisect_left(t, x) bisect_left(t, x) t_ind q = map(int,input().split()) map(int,input().split()) q s = [int(input()) for _ in range(a)] [int(input()) for _ in range(a)] s s = [-inf] + s + [inf] [-inf] + s + [inf] s res = inf inf res t = [-inf] + t + [inf] [-inf] + t + [inf] t x = int(input()) int(input()) x a, b, q = map(int,input().split()) map(int,input().split()) a st = abs(cand_s - cand_t) abs(cand_s - cand_t) st dx = min(abs(cand_s - x), abs(cand_t - x)) min(abs(cand_s - x), abs(cand_t - x)) dx
from bisect import *
a, b, q = map(int,input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
inf = 10 ** 18
s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

for i in range(q):
    x = int(input())
    s_ind = bisect_left(s, x)
    t_ind = bisect_left(t, x)
    
    res = inf
    for cand_s in [s[s_ind - 1], s[s_ind]]:
        for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
    print(res)