/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
// #define INF (0x3f3f3f3f)
#define INF 1e+15

/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

// int dx[] = {-1, 0, 1, 0};
// int dy[] = {0, -1, 0, 1};
int dx[] = {-1, 0, 1};
int dy[] = {-1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A, B);
    Cini(Q);
    vector<long long> s(A), t(B), x(Q);
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    rep(i, Q) cin >> x[i];
    sort(All(s));
    sort(All(t));
    int s_min = *min_element(All(s));
    int s_max = *max_element(All(s));
    int t_min = *min_element(All(t));
    int t_max = *max_element(All(t));
    rep(i, Q) {
        int t_near1, t_near2, s_near1, s_near2;

        auto t_near_ptr = upper_bound(All(t), x[i]);
        auto s_near_ptr = upper_bound(All(s), x[i]);

        if(t_near_ptr==t.end()){ t_near1 = *(--t_near_ptr);  t_near2=t_near1;}
        else if(t_near_ptr==t.begin()){ t_near1 = *(t_near_ptr);  t_near2=t_near1;}
        else {t_near1 = *t_near_ptr; t_near2=*(--t_near_ptr);}

        if(s_near_ptr==s.end()){ s_near1 = *(--s_near_ptr);  s_near2=s_near1;}
        else if(s_near_ptr==s.begin()){ s_near1 = *(s_near_ptr);  s_near2=s_near1;}
        else { s_near1 = *s_near_ptr; s_near2=*(--s_near_ptr);}

        int ans1 = abs(t_near1 - x[i]) + abs(s_near1 - t_near1);
        int ans2 = abs(t_near1 - x[i]) + abs(s_near2 - t_near1);
        int ans3 = abs(t_near2 - x[i]) + abs(s_near1 - t_near2);
        int ans4 = abs(t_near2 - x[i]) + abs(s_near2 - t_near2);
        int ans5 = abs(s_near1 - x[i]) + abs(t_near1 - s_near1);
        int ans6 = abs(s_near1 - x[i]) + abs(t_near2 - s_near1);
        int ans7 = abs(s_near2 - x[i]) + abs(t_near1 - s_near2);
        int ans8 = abs(s_near2 - x[i]) + abs(t_near2 - s_near2);
        cout << min(ans1,
                    min(ans2,
                        min(ans3,
                            min(ans4, min(ans5, min(ans6, min(ans7, ans8)))))))
             << nn;
    }
    return 0;
}


Measured memory_bytes: 3712