// {{{ header
#include <bits/stdc++.h>
using namespace std;

using i8   = int8_t;
using u8   = uint8_t;
using i16  = int16_t;
using u16  = uint16_t;
using i32  = int32_t;
using u32  = uint32_t;
using i64  = int64_t;
using u64  = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;

using f32  = float;
using f64  = double;
using f80  = __float80;
using f128 = __float128;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'000LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// {{{ util
#define FOR(i, start, end) for(i64 i = (start), i##_end=(end); i < i##_end; ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cc) { return (f)(begin(cc), end(cc), ## __VA_ARGS__); })(c))

template<typename T, typename U>
bool chmax(T& xmax, const U& x) {
    if(xmax < x) {
        xmax = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T, typename U>
bool chmin(T& xmin, const U& x) {
    if(x < xmin) {
        xmin = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T>
void RD(T& x) {
    cin >> x;
#ifdef PROCON_LOCAL
    assert(cin);
#endif
}

template<typename T>
void RD(vector<T>& v, int n) {
    v.reserve(n);
    REP(_, n) {
        T e; RD(e);
        v.emplace_back(e);
    }
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for(auto first = begin(v), it = first; it != end(v); ++it) {
        if(it != first)
            out << ' ';
        out << *it;
    }
    return out;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1,T2>& p) {
    return out << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
void PRINT(const T& x) {
    cout << x;
}

template<typename T>
void PRINTLN(const T& x) {
    PRINT(x);
    cout << '\n';
}

template<typename T>
void DBG_IMPL(i64 line, const char* expr, const T& value) {
#ifdef PROCON_LOCAL
    cerr << "[LINE " << line << "]: ";
    cerr << expr << " = " << value << "\n";
#endif
}

#define DBG(expr) DBG_IMPL(__LINE__, #expr, (expr))
// }}}

// {{{ init
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
#ifdef PROCON_LOCAL
        cerr << fixed << setprecision(IOS_PREC);
#endif
        if(AUTOFLUSH)
            cout << unitbuf;
    }
};
// }}}

//--------------------------------------------------------------------

i64 A, B;
i64 Q;
vector<i64> S;
vector<i64> T;
vector<i64> X;

vector<pair<i64,i64>> search(const vector<i64>& v, i64 x) {
    vector<pair<i64,i64>> res;

    auto it = ALL(lower_bound, v, x);
    if(it != begin(v)) {
        res.emplace_back(*prev(it), abs(*prev(it) - x));
    }
    if(it != end(v)) {
        res.emplace_back(*it, abs(*it - x));
    }

    return res;
}

void solve_one(i64 x) {
    i64 ans = INF;

    // 先にSを探索
    for(const auto& p : search(S,x)) {
        i64 y,d1; tie(y,d1) = p;
        for(const auto& q : search(T,y)) {
            i64 d2; tie(ignore,d2) = q;
            chmin(ans, d1+d2);
        }
    }

    // 先にTを探索
    for(const auto& p : search(T,x)) {
        i64 y,d1; tie(y,d1) = p;
        for(const auto& q : search(S,y)) {
            i64 d2; tie(ignore,d2) = q;
            chmin(ans, d1+d2);
        }
    }

    PRINTLN(ans);
}

void solve() {
    for(auto x : X) {
        solve_one(x);
    }
}

signed main() {
    RD(A);
    RD(B);
    RD(Q);
    RD(S, A);
    RD(T, B);
    RD(X, Q);

    solve();

    return 0;
}


Measured memory_bytes: 3712