#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

use std::cmp::Ordering;
trait BinarySearch<T> {
    fn upper_bound(&self, value: &T) -> usize;
    fn lower_bound(&self, value: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, value: &T) -> usize {
        let (mut l, mut r) = (0, self.len());
        while l < r {
            let mid = (l + r) / 2;
            match self[mid].cmp(value) {
                Ordering::Greater => {
                    r = mid;
                }
                Ordering::Equal | Ordering::Less => {
                    l = mid + 1;
                }
            };
        }
        r
    }

    fn lower_bound(&self, value: &T) -> usize {
        let (mut l, mut r) = (0, self.len());
        while l < r {
            let mid = (l + r) / 2;
            match self[mid].cmp(&value) {
                Ordering::Equal | Ordering::Greater => {
                    r = mid;
                }
                Ordering::Less => {
                    l = mid + 1;
                }
            };
        }
        r
    }
}

fn main() {
    input! {
        a: usize,
        b: usize,
        q: usize,
        s: [usize; a],
        t: [usize; b],
        x: [usize; q],
    }
    let mut ca = vec![];
    let mut ba = vec![];

    for i in 0..a {
        let p = t.lower_bound(&s[i]);
        let mut c = 1 << 50;
        if p < t.len() {
            c = min(c, t[p] - s[i]);
        }
        if p > 0 {
            c = min(c, s[i] - t[p - 1]);
        }
        ca.push((s[i], c));
    }
    for i in 0..b {
        let p = s.lower_bound(&t[i]);
        let mut c = 1 << 50;
        if p < s.len() {
            c = min(c, s[p] - t[i]);
        }
        if p > 0 {
            c = min(c, t[i] - s[p - 1]);
        }
        ba.push((t[i], c));
    }
    ca.sort();
    ba.sort();
    // for i in 0..ca.len() {
    //     println!("{}, {}", ca[i].0, ca[i].1);
    // }
    // for i in 0..ba.len() {
    //     println!("{}, {}", ba[i].0, ba[i].1);
    // }
    for i in 0..q {
        let mut a: usize = 1 << 50;
        let p = ca.lower_bound(&(x[i], 0));
        if p < ca.len() {
            a = min(a, ca[p].0 - x[i] + ca[p].1);
        }
        if p > 0 {
            a = min(a, x[i] - ca[p - 1].0 + ca[p - 1].1);
        }
        let p = ba.lower_bound(&(x[i], 0));
        if p < ba.len() {
            a = min(a, ba[p].0 - x[i] + ba[p].1);
        }
        if p > 0 {
            a = min(a, x[i] - ba[p - 1].0 + ba[p - 1].1);
        }
        println!("{}", a);
    }
}


Measured memory_bytes: 13676