/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll x, y, q;
        cin >> x >> y >> q;
        ll a[x], b[y];
        rep(i, x) cin >> a[i];
        rep(i, y) cin >> b[i];
        sort(a, a+x); sort(b, b+y);
        rep(i, q) { ll ki, val = 0;
            cin >> ki;
            ll in1 = lower_bound(a, a+x, ki) - a;
            ll in2 = lower_bound(b, b+y, ki) - b;
            ll x1, x2, y1, y2;
            if(in1 == 0) x1 = 0, x2 = 0;
            else if(in1 == x ) x1 = in1-1, x2 = in1 - 1;
            else x1 = in1, x2 = in1 - 1;

            if(in2 == 0) y1 = 0, y2 = 0;
            else if(in2 == y ) y1 = in2-1, y2 = in2 - 1;
            else y1 = in2, y2 = in2 - 1;

            //cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
            //cout << abs(a[x1] - ki) << " " << min(abs(a[x1] - b[y1]), abs(a[x1] - b[y2])) << endl;
            //cout << abs(a[x2] - ki) << " " << min(abs(a[x2] - b[y1]), abs(a[x2] - b[y2])) << endl;
            //cout << abs(b[y1] - ki) << " " << min(abs(b[y1] - a[x1]), abs(b[y1] - a[x2])) << endl;
            //cout << abs(b[y2] - ki) << " " << min(abs(b[y2] - a[x1]), abs(b[y2] - a[x2])) << endl;

            val = min({ abs(a[x1] - ki) + min(abs(a[x1] - b[y1]), abs(a[x1] - b[y2])),
                        abs(a[x2] - ki) + min(abs(a[x2] - b[y1]), abs(a[x2] - b[y2])),
                        abs(b[y1] - ki) + min(abs(b[y1] - a[x1]), abs(b[y1] - a[x2])),
                        abs(b[y2] - ki) + min(abs(b[y2] - a[x1]), abs(b[y2] - a[x2])),
                    });
            cout << val << endl;
        }
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
     */ 
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 2944