open Printf open Scanf
open Array

let iia k = init k (fun _ -> scanf " %d" @@ fun v -> v)
let binary_search ng ok f = let d = if ng <= ok then 1 else -1 in
  let rec f0 ng ok =
    if abs (ok - ng) <= 1 then ok
    else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok
  in f0 (ng-d) (ok+d)
let right a v = binary_search 0 (length a - 1) (fun i -> a.(i) > v)
let left  a v = binary_search (length a - 1) 0 (fun i -> a.(i) < v)

let inf = 1000000000000

let () = scanf " %d %d %d" @@ fun a b q ->
  let s = iia a in
  let t = iia b in
  let x = iia q in
  sort compare s;
  sort compare t;
  let gs i dir =
    if i<0 || i >= a then (
      if dir=`L then -inf else inf
    ) else s.(i) in
  let gt i dir =
    if i<0 || i >= b then (
      if dir=`L then -inf else inf
    ) else t.(i) in
  iter (fun x ->
    let ls,rs = left s x, right s x in
    let lt,rt = left t x, right t x in
    let ls,rs,lt,rt =
      (gs ls `L),(gs rs `R),
      (gt lt `L),(gt rt `R)
    in
    (* printf ":::::: %16d %16d ; %16d %16d\n"
      ls rs lt rt; *)
    let res = [|
      abs (x - min ls lt);
      abs (x-ls) + abs (rt-ls);
      abs (max rs rt - x);
      abs (rs-x) + abs (rs-lt);
      abs (x-lt) + abs (rs-lt);
      abs (rt-x) + abs (rt-ls);
    |] in
    (* iter (printf "%d ") res;
    printf " :: "; *)
    printf "%d\n" @@ fold_left min inf res
    (* let c1 = abs (x - min ls lt) in
    let c2 = abs (x-ls) + abs (rt-ls) in
    let c3 = abs (x + max rs rt) in
    let c4 = abs (rs-x) + abs (rs-rt) in
    printf "%d %d %d %d ::"
      c1 c2 c3 c4;
    printf "%d\n" @@ fold_left min inf [|c1;c2;c3;c4|] *)
  ) x


