import sys
input = sys.stdin.readline
from bisect import *

A, B, Q = map(int, input().split())
s = [-10**18]+[int(input()) for _ in range(A)]+[10**18]
t = [-10**18]+[int(input()) for _ in range(B)]+[10**18]

for _ in range(Q):
    x = int(input())
    i = bisect_left(s, x)
    sl = s[i-1]
    sr = s[i]
    i = bisect_left(t, x)
    tl = t[i-1]
    tr = t[i]
    ans = 10**18
    
    for fi in [sl, sr]:
        for se in [tl, tr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    for fi in [tl, tr]:
        for se in [sl, sr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 = [-10**18]+[int(input()) for _ in range(A)]+[10**18] s [-10**18]+[int(input()) for _ in range(A)]+[10**18] [-10**18]+[int(input()) for _ in range(A)] [-10**18] -10**18 -10 18 [int(input()) for _ in range(A)] [10**18] 10**18 10 18 int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t = [-10**18]+[int(input()) for _ in range(B)]+[10**18] t [-10**18]+[int(input()) for _ in range(B)]+[10**18] [-10**18]+[int(input()) for _ in range(B)] [-10**18] -10**18 -10 18 [int(input()) for _ in range(B)] [10**18] 10**18 10 18 for _ in range(Q):
    x = int(input())
    i = bisect_left(s, x)
    sl = s[i-1]
    sr = s[i]
    i = bisect_left(t, x)
    tl = t[i-1]
    tr = t[i]
    ans = 10**18
    
    for fi in [sl, sr]:
        for se in [tl, tr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    for fi in [tl, tr]:
        for se in [sl, sr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input i = bisect_left(s, x) i bisect_left(s, x) bisect_left s x sl = s[i-1] sl s[i-1] s i-1 i 1 sr = s[i] sr s[i] s i i = bisect_left(t, x) i bisect_left(t, x) bisect_left t x tl = t[i-1] tl t[i-1] t i-1 i 1 tr = t[i] tr t[i] t i ans = 10**18 ans 10**18 10 18 for fi in [sl, sr]:
        for se in [tl, tr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
     fi [sl, sr] sl sr for se in [tl, tr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
     se [tl, tr] tl tr ans = min(ans, abs(fi-x)+abs(se-fi)) ans min(ans, abs(fi-x)+abs(se-fi)) min ans abs(fi-x)+abs(se-fi) abs(fi-x) abs fi-x fi x abs(se-fi) abs se-fi se fi for fi in [tl, tr]:
        for se in [sl, sr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
     fi [tl, tr] tl tr for se in [sl, sr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
     se [sl, sr] sl sr ans = min(ans, abs(fi-x)+abs(se-fi)) ans min(ans, abs(fi-x)+abs(se-fi)) min ans abs(fi-x)+abs(se-fi) abs(fi-x) abs fi-x fi x abs(se-fi) abs se-fi se fi print(ans) print ans Q = map(int, input().split()) map(int, input().split()) Q s = [-10**18]+[int(input()) for _ in range(A)]+[10**18] [-10**18]+[int(input()) for _ in range(A)]+[10**18] s t = [-10**18]+[int(input()) for _ in range(B)]+[10**18] [-10**18]+[int(input()) for _ in range(B)]+[10**18] t tr = t[i] t[i] tr tl = t[i-1] t[i-1] tl sr = s[i] s[i] sr ans = min(ans, abs(fi-x)+abs(se-fi)) min(ans, abs(fi-x)+abs(se-fi)) ans ans = 10**18 10**18 ans x = int(input()) int(input()) x ans = min(ans, abs(fi-x)+abs(se-fi)) min(ans, abs(fi-x)+abs(se-fi)) ans A, B, Q = map(int, input().split()) map(int, input().split()) A B, Q = map(int, input().split()) map(int, input().split()) B sl = s[i-1] s[i-1] sl input = sys.stdin.readline sys.stdin.readline input i = bisect_left(s, x) bisect_left(s, x) i i = bisect_left(t, x) bisect_left(t, x) i
import sys
input = sys.stdin.readline
from bisect import *

A, B, Q = map(int, input().split())
s = [-10**18]+[int(input()) for _ in range(A)]+[10**18]
t = [-10**18]+[int(input()) for _ in range(B)]+[10**18]

for _ in range(Q):
    x = int(input())
    i = bisect_left(s, x)
    sl = s[i-1]
    sr = s[i]
    i = bisect_left(t, x)
    tl = t[i-1]
    tr = t[i]
    ans = 10**18
    
    for fi in [sl, sr]:
        for se in [tl, tr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    for fi in [tl, tr]:
        for se in [sl, sr]:
            ans = min(ans, abs(fi-x)+abs(se-fi))
    
    print(ans)