{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V 
import Debug.Trace
main :: IO ()
main = readLine >>= mapM (flip replicateM readLn) >>= main'
    where
        main' [ss, ts, xs] = printRes . solve xs $ build ss ts
        printRes = mapM_ print

solve :: [Int] -> (V.Vector Int, V.Vector Int) -> [Int]
solve xs (!sv, !tv) = map answer xs
    where
        sn = V.length sv
        tn = V.length tv
        answer x = minimum [pat0, pat1, pat2, pat3]
            where
                pat0 = abs (spv - tnv) + min (abs $ x - spv) (abs $ x - tnv)
                pat1 = abs (snv - tpv) + min (abs $ x - snv) (abs $ x - tpv)
                pat2 = max (abs $ x - snv) (abs $ x - tnv)
                pat3 = max (abs $ x - spv) (abs $ x - tpv)
                spv = sv V.! spi
                snv = sv V.! sni
                tpv = tv V.! tpi
                tnv = tv V.! tni
                (spi, sni) = check $ bsf 0 sn x sv
                (tpi, tni) = check $ bsf 0 tn x tv
        check i = (i, i + 1)

bsf :: Int -> Int -> Int -> V.Vector Int -> Int
bsf l h x v
    | l == m = l
    | x < mv = bsf l m x v
    | otherwise = bsf m h x v
    where
        m = (l + h) `div` 2
        mv = v V.! m

build :: [Int] -> [Int] -> (V.Vector Int, V.Vector Int)
build ss ts = (sv, tv)
    where
        sv = V.fromList $ (-10^11) : ss ++ [(10^11)] 
        tv = V.fromList $ (-10^11) : ts ++ [(10^11)]

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine