import Data.Array
import Control.Monad

import qualified Data.Map.Strict as M

find_near_idxs::Array Int Int -> Int -> (Int,Int)
find_near_idxs ar x = let (st,ed) = bounds ar in  rec ar x (st,ed)
                            where rec ar x (a,b) = if a+1 >= b
                                                      then (a,b)
                                                      else if ar!(div (a+b) 2) <= x
                                                              then rec ar x (div (a+b) 2,b)
                                                              else rec ar x (a,div (a+b) 2)

find_near_idxs2::M.Map Int () -> Int -> [Int]
find_near_idxs2 m x = ((map (\ (Just (v,_)) -> v)).(filter (Nothing/=))) [M.lookupLE x m,M.lookupGE x m]

step::Array Int Int -> (Int,Int) -> [(Int,Int)]
step ar (x,cost) = let (i,j) = find_near_idxs ar x in [(ar!i,cost + (abs ((ar!i) - x))),(ar!j,cost + (abs ((ar!j) - x)))]

step2::M.Map Int () -> (Int,Int) -> [(Int,Int)]
step2 m (x,cost) = let ls = find_near_idxs2 m x in [(y,abs (x-y)+cost)|y<-ls]

solver::Array Int Int -> Array Int Int -> Int -> Int
solver ar_1 ar_2 x = let pat_12 = (minimum.(map snd).concat.(map (step ar_2)).(step ar_1)) (x,0) in
                     let pat_21 = (minimum.(map snd).concat.(map (step ar_1)).(step ar_2)) (x,0) in
                     min pat_12 pat_21

solver2::M.Map Int () -> M.Map Int () -> Int -> Int
solver2 m_1 m_2 x = let pat_12 = (minimum.(map snd).concat.(map (step2 m_2)).(step2 m_1)) (x,0) in
                    let pat_21 = (minimum.(map snd).concat.(map (step2 m_1)).(step2 m_2)) (x,0) in
                    min pat_12 pat_21

main::IO()
main=do
  (a:b:q:[])<-return.(map read).words=<<getLine
  dat_s<-forM [1..a] (\_->return.read=<<getLine)
  dat_t<-forM [1..b] (\_->return.read=<<getLine)
  let m_s = M.fromList [(v,())|v<-dat_s]
  let m_t = M.fromList [(w,())|w<-dat_t]
  inputs <- forM [1..q] (\_-> return.read=<<getLine)
  forM_ inputs  (print.(solver2 m_s m_t))