import Data.Maybe (isJust)
import qualified Data.IntSet as S

main :: IO ()
main = do
  [a, b, q] <- map read . words <$> getLine
  stxs <- map read . lines <$> getContents
  let
    (ss, (ts, xs)) = ((,) <$> fst <*> splitAt b . snd) . splitAt a $ stxs
    ss' = S.fromDistinctAscList ss
    ts' = S.fromDistinctAscList ts
    f x = min (g sgl tgl) (g tgl sgl)
      where
        sgl = lg ss'
        tgl = lg ts'
        lg = sequenceA . sequenceA [S.lookupLT, S.lookupGT] $ x
        g sgl tgl = minimum . map (maybe undefined id) . filter isJust . map ((snd . foldl (\(y, d) -> (,) <$> id <*> (d +) . dist y) (x, 0) <$>) . sequenceA) . sequenceA $ [sgl, tgl]
  mapM_ (print . f) xs

dist :: Num a => a -> a -> a
dist x y = abs $ y - x
