#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

#define INF (int)1e12 + 7
#define int long long

struct qp
{
    int ls, lt, rs, rt;
};

int get_min(int q, int ls, int lt, int rs, int rt)
{
    pair<int, int> p[4] = {{ls, lt}, {ls, rt}, {rs, lt}, {rs, rt}};
    int ans = INF;
    for (int i = 0; i < 4; i++)
    {
        ans = min(ans, abs(q - p[i].first) + abs(p[i].first - p[i].second));
        ans = min(ans, abs(q - p[i].second) + abs(p[i].first - p[i].second));
    }
    return ans;
}

signed main()
{
    int A, B, Q;
    cin >> A >> B >> Q;
    // distance, type
    //
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    vector<int> vq(Q);
    for (int i = 0; i < A; i++)
    {
        int s;
        cin >> s;

        q.push({s, -2});
    }
    for (int i = 0; i < B; i++)
    {
        int t;
        cin >> t;

        q.push({t, -1});
    }
    for (int i = 0; i < Q; i++)
    {
        int hoge;
        cin >> hoge;
        vq[i] = hoge;
        q.push({hoge, i});
    }

    int ls = -INF;
    int lt = -INF;
    //q, ans
    map<int, int> mans;
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> no_rs_rt;
    // d, ls, lt, rt
    priority_queue<pair<int, pair<pair<int, int>, int>>, vector<pair<int, pair<pair<int, int>, int>>>, greater<pair<int, pair<pair<int, int>, int>>>> no_rs;
    priority_queue<pair<int, pair<pair<int, int>, int>>, vector<pair<int, pair<pair<int, int>, int>>>, greater<pair<int, pair<pair<int, int>, int>>>> no_rt;

    while (!q.empty())
    {
        int d = q.top().first;
        int type = q.top().second;
        q.pop();
        if (type == -2)
        {
            ls = d;
            while (!no_rs_rt.empty())
            {
                int tmp_q = no_rs_rt.top().first;
                int tmp_ls = no_rs_rt.top().second.first;
                int tmp_lt = no_rs_rt.top().second.second;

                no_rt.push({tmp_q, {{tmp_ls, tmp_lt}, d}});
                no_rs_rt.pop();
            }
            while (!no_rs.empty())
            {
                int tmp_q = no_rs.top().first;
                int tmp_ls = no_rs.top().second.first.first;
                int tmp_lt = no_rs.top().second.first.second;
                int tmp_rt = no_rs.top().second.second;
                mans[tmp_q] = get_min(tmp_q, tmp_ls, tmp_lt, d, tmp_rt);
                no_rs.pop();
            }
        }
        else if (type == -1)
        {
            lt = d;
            while (!no_rs_rt.empty())
            {
                int tmp_q = no_rs_rt.top().first;
                int tmp_ls = no_rs_rt.top().second.first;
                int tmp_lt = no_rs_rt.top().second.second;

                no_rs.push({tmp_q, {{tmp_ls, tmp_lt}, d}});
                no_rs_rt.pop();
            }
            while (!no_rt.empty())
            {
                int tmp_q = no_rt.top().first;
                int tmp_ls = no_rt.top().second.first.first;
                int tmp_lt = no_rt.top().second.first.second;
                int tmp_rs = no_rt.top().second.second;
                mans[tmp_q] = get_min(tmp_q, tmp_ls, tmp_lt, tmp_rs, d);
                no_rt.pop();
            }
        }
        else
        {
            no_rs_rt.push({d, {ls, lt}});
        }
    }

    while (!no_rs_rt.empty())
    {
        int tmp_q = no_rs_rt.top().first;
        int tmp_ls = no_rs_rt.top().second.first;
        int tmp_lt = no_rs_rt.top().second.second;
        mans[tmp_q] = get_min(tmp_q, tmp_ls, tmp_lt, INF, INF);
        no_rs_rt.pop();
    }

    while (!no_rs.empty())
    {
        int tmp_q = no_rs.top().first;
        int tmp_ls = no_rs.top().second.first.first;
        int tmp_lt = no_rs.top().second.first.second;
        int tmp_rt = no_rs.top().second.second;
        mans[tmp_q] = get_min(tmp_q, tmp_ls, tmp_lt, INF, tmp_rt);
        no_rs.pop();
    }

    while (!no_rt.empty())
    {
        int tmp_q = no_rt.top().first;
        int tmp_ls = no_rt.top().second.first.first;
        int tmp_lt = no_rt.top().second.first.second;
        int tmp_rs = no_rt.top().second.second;
        mans[tmp_q] = get_min(tmp_q, tmp_ls, tmp_lt, tmp_rs, INF);
        no_rt.pop();
    }

    for (int i = 0; i < Q; i++)
    {
        cout << mans[vq[i]] << endl;
    }
}

Measured memory_bytes: 19688