import bisect
 
a, b, q = map(int, input().split())
s = [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')]
 
 
for _ in range(q):
    
    x = int(input())
    
    s_index = bisect.bisect_right(s, x)
    s_right = s[s_index]
    s_left = s[s_index - 1]
    t_index = bisect.bisect_right(t, x)
    t_right = t[t_index]
    t_left = t[t_index - 1]
    
    ans = float('inf')
    
    # 最初に寺を訪れる場合
    ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    )
    # 最初に神社を訪れる場合
    ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    )
        
    print(ans) import bisect bisect 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 = [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')] s [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')] [float('-inf')] + [int(input()) for _ in range(a)] [float('-inf')] float('-inf') float '-inf' [int(input()) for _ in range(a)] [float('inf')] float('inf') float '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 = [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')] t [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')] [float('-inf')] + [int(input()) for _ in range(b)] [float('-inf')] float('-inf') float '-inf' [int(input()) for _ in range(b)] [float('inf')] float('inf') float 'inf' for _ in range(q):
    
    x = int(input())
    
    s_index = bisect.bisect_right(s, x)
    s_right = s[s_index]
    s_left = s[s_index - 1]
    t_index = bisect.bisect_right(t, x)
    t_right = t[t_index]
    t_left = t[t_index - 1]
    
    ans = float('inf')
    
    # 最初に寺を訪れる場合
    ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    )
    # 最初に神社を訪れる場合
    ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    )
        
    print(ans) _ range(q) range q x = int(input()) x int(input()) int input() input s_index = bisect.bisect_right(s, x) s_index bisect.bisect_right(s, x) bisect.bisect_right bisect bisect_right s x s_right = s[s_index] s_right s[s_index] s s_index s_left = s[s_index - 1] s_left s[s_index - 1] s s_index - 1 s_index 1 t_index = bisect.bisect_right(t, x) t_index bisect.bisect_right(t, x) bisect.bisect_right bisect bisect_right t x t_right = t[t_index] t_right t[t_index] t t_index t_left = t[t_index - 1] t_left t[t_index - 1] t t_index - 1 t_index 1 ans = float('inf') ans float('inf') float 'inf' ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    ) ans min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    ) min ans abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)) abs(x - s_right) abs x - s_right x s_right min(abs(s_right - t_right), abs(s_right - t_left)) min abs(s_right - t_right) abs s_right - t_right s_right t_right abs(s_right - t_left) abs s_right - t_left s_right t_left abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)) abs(x - s_left) abs x - s_left x s_left min(abs(s_left - t_right), abs(s_left - t_left)) min abs(s_left - t_right) abs s_left - t_right s_left t_right abs(s_left - t_left) abs s_left - t_left s_left t_left ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    ) ans min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    ) min ans abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)) abs(x - t_right) abs x - t_right x t_right min(abs(t_right - s_right), abs(t_right - s_left)) min abs(t_right - s_right) abs t_right - s_right t_right s_right abs(t_right - s_left) abs t_right - s_left t_right s_left abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)) abs(x - t_left) abs x - t_left x t_left min(abs(t_left - s_right), abs(t_left - s_left)) min abs(t_left - s_right) abs t_left - s_right t_left s_right abs(t_left - s_left) abs t_left - s_left t_left s_left print(ans) print ans q = map(int, input().split()) map(int, input().split()) q s_right = s[s_index] s[s_index] s_right ans = float('inf') float('inf') ans b, q = map(int, input().split()) map(int, input().split()) b t_left = t[t_index - 1] t[t_index - 1] t_left ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    ) min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    ) ans t_right = t[t_index] t[t_index] t_right t_index = bisect.bisect_right(t, x) bisect.bisect_right(t, x) t_index a, b, q = map(int, input().split()) map(int, input().split()) a t = [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')] [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')] t s = [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')] [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')] s x = int(input()) int(input()) x s_index = bisect.bisect_right(s, x) bisect.bisect_right(s, x) s_index s_left = s[s_index - 1] s[s_index - 1] s_left ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    ) min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    ) ans
import bisect
 
a, b, q = map(int, input().split())
s = [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')]
 
 
for _ in range(q):
    
    x = int(input())
    
    s_index = bisect.bisect_right(s, x)
    s_right = s[s_index]
    s_left = s[s_index - 1]
    t_index = bisect.bisect_right(t, x)
    t_right = t[t_index]
    t_left = t[t_index - 1]
    
    ans = float('inf')
    
    # 最初に寺を訪れる場合
    ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    )
    # 最初に神社を訪れる場合
    ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    )
        
    print(ans)