#include <bits/stdc++.h>

#define forn(i,n) for(tint i = 0; i < tint(n); i++)
#define pb push_back
#define mp make_pair
#define dforn(i,n) for(tint i = tint(n) - 1; i >= 0; i--)
#define all(c) (c).begin(),(c).end()

typedef long long int tint;

using namespace std;

const tint maxN = 2e5+2;

const tint inf = 1e18;

tint binarySearch(vector<tint>& arreglo, tint n, tint k, bool isLow){
	tint low = 0;
	tint high = n-1;
	if (arreglo[low] > k) return low;
	if (arreglo[high] <= k) return high;
	while(low < high - 1){
		tint med = low + (high-low)/2;
		if (arreglo[med] <= k) low = med;
		else high = med;
	}
	if (isLow) return low;
	else return (arreglo[low] == k ? low : high);
}

int main(){
	#ifdef ACMTUYO
		freopen("in.txt", "r", stdin);
	#endif
	tint n,m,k,q;
	cin >> n >> m >> k >> q;
	vector<tint> columnas;

	tint minimoM[n], maximoM[n];
	forn(i,n){
		minimoM[i] = -1, maximoM[i] = -1;
	}
	forn(i,k){
		tint r, c;
		cin >> r >> c; r--; c--;
		if (minimoM[r] == -1){
			minimoM[r] = c, maximoM[r] = c;
		} else {
			minimoM[r] = min(c, minimoM[r]);
			maximoM[r] = max(c, maximoM[r]);
		}
	}
	bool prendidas[m]; forn(i,m) prendidas[i] = false;
	forn(i,q){
		tint x;
		cin >> x; x--;
		columnas.pb(x);
		prendidas[x] = true;
	}
	tint cantNoNulos = 0;
	forn(i,n) if (minimoM[i] >= 0) cantNoNulos += 1;
	tint minimo[cantNoNulos], maximo[cantNoNulos];
	tint j = 0;
	//~ forn(i,n) cout << minimoM[i] << " " << maximoM[i] << endl;
	//~ cout << endl;
	forn(i,cantNoNulos){
		while (minimoM[j] == -1) j++;
		minimo[i] = minimoM[j];
		maximo[i] = maximoM[j];
		j++;
	}
	tint left[m], right[m]; left[0] = columnas[0], right[m-1] = columnas[columnas.size()-1];
	forn(i, m) if(i){
		if (prendidas[i]){
			left[i] = i;
		} else {
			left[i] = left[i-1];
		}
	}
	dforn(i, m) if(i<m-1){
		if (prendidas[i]){
			right[i] = i;
		} else {
			right[i] = right[i+1];
		}
	}
	tint res = 0;
	res += j-1;
	n = cantNoNulos;
	sort(all(columnas));
	tint dp[n][2];
	forn(i,n) forn(l,2) dp[i][l] = inf;
	tint cants[n][2];//minimo+maximo
	forn(i,n) cants[i][0] = minimo[i];
	forn(i,n) cants[i][1] = maximo[i];
	forn(i,n){
		if (i == 0){
			dp[i][0] = 2*maximo[i] - minimo[i];
			dp[i][1] = maximo[i];
		} else {
			tint s = (tint)columnas.size();
			tint idx[2][2];
			idx[1][0] = left[maximo[i-1]];   //binarySearch(columnas, s, maximo[i-1], true);
			idx[1][1] = right[maximo[i-1]]; //binarySearch(columnas, s, maximo[i-1], false);
			idx[0][0] = left[minimo[i-1]];   //binarySearch(columnas, s, minimo[i-1], true);
			idx[0][1] = right[minimo[i-1]]; //binarySearch(columnas, s, minimo[i-1], false);
			//~ cout << idxLeftMin <<" " << idxLeftMax << " " <<idxRightMin << " " << idxRightMax << endl;
			//~ idxLeftMax  = columnas[idxLeftMax];
			//~ idxLeftMin  = columnas[idxLeftMin];
			//~ idxRightMax = columnas[idxRightMax];
			//~ idxRighcotMin = columnas[idxRightMin];
			//~ cout << idxLeftMin <<" " << idxRightMin << " " << idxLeftMax<< " " << idxRightMax << endl;

			forn(valorArriba,2){
				forn(costadoAbajo,2){
					forn(valorAbajo,2){
						tint posible = dp[i-1][valorAbajo] + abs(cants[i-1][valorAbajo] - idx[valorAbajo][costadoAbajo]) + abs(idx[valorAbajo][costadoAbajo] - cants[i][valorArriba]);
						if (valorArriba == 0){
							posible += 2 * (idx[valorAbajo][costadoAbajo] < cants[i][1])* abs(cants[i][1] - idx[valorAbajo][costadoAbajo]);
						} else {
							posible += 2 * (idx[valorAbajo][costadoAbajo] > cants[i][0])* abs(cants[i][0] - idx[valorAbajo][costadoAbajo]);
						}
						dp[i][valorArriba] = min(dp[i][valorArriba], posible);
					}
				}
			}
			//~ dp[i][0] = min(dp[i][0], dp[i-1][1] + abs(maximo[i-1] - idxRightMax) + abs(idxRightMax - minimo[i]) + 2 * (idxRightMax < maximo[i])* abs(maximo[i] - idxRightMax));

			//~ dp[i][0] = min(dp[i][0], dp[i-1][1] + abs(maximo[i-1] - idxRightMax) + abs(idxRightMax - minimo[i]) + 2 * (idxRightMax < maximo[i])* abs(maximo[i] - idxRightMax));
			//~ dp[i][0] = min(dp[i][0], dp[i-1][1] + abs(maximo[i-1] - idxLeftMax)  + abs(idxLeftMax  - minimo[i]) + 2 * (idxLeftMax  < maximo[i])* abs(maximo[i] - idxLeftMax));
			//~ dp[i][0] = min(dp[i][0], dp[i-1][0] + abs(minimo[i-1] - idxRightMin) + abs(idxRightMin - minimo[i]) + 2 * (idxRightMin < maximo[i])* abs(maximo[i] - idxRightMin));
			//~ dp[i][0] = min(dp[i][0], dp[i-1][0] + abs(minimo[i-1] - idxLeftMin)  + abs(idxLeftMin  - minimo[i]) + 2 * (idxLeftMin  < maximo[i])* abs(maximo[i] - idxLeftMin));

			//~ dp[i][1] = min(dp[i][1], dp[i-1][1] + abs(maximo[i-1] - idxRightMax) + abs(idxRightMax - maximo[i]) + 2 * (idxRightMax > minimo[i])* abs(minimo[i] - idxRightMax));
			//~ dp[i][1] = min(dp[i][1], dp[i-1][1] + abs(maximo[i-1] - idxLeftMax)  + abs(idxLeftMax  - maximo[i]) + 2 * (idxLeftMax  > minimo[i])* abs(minimo[i] - idxLeftMax));
			//~ dp[i][1] = min(dp[i][1], dp[i-1][0] + abs(minimo[i-1] - idxRightMin) + abs(idxRightMin - maximo[i]) + 2 * (idxRightMin > minimo[i])* abs(minimo[i] - idxRightMin));
			//~ dp[i][1] = min(dp[i][1], dp[i-1][0] + abs(minimo[i-1] - idxLeftMin)  + abs(idxLeftMin  - maximo[i]) + 2 * (idxLeftMin  > minimo[i])* abs(minimo[i] - idxLeftMin));
		 }
	}
	forn(i,n){
		forn(l,2) cout << dp[i][l] << " ";
		cout << endl;
	}
	res += min(dp[n-1][0], dp[n-1][1]);
	cout << res << endl;
	return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e18;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    if (n != 1)
        cout << ans + res[0][0];
    else
        cout << ((ups.front() <= points.back().front()) ? ans : ans - 2 * (points.back().front() - ups.front()));
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e18;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    cout << ans + res[0][0];
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e18;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    a[0].emplace_back(0);
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                                           res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        if (rpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tl - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - rpos2) + abs(ntr - rpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (lpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - lpos2) + abs(ntl - lpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    cout << ans + res[0][0];
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    cout << ans + res[0][0];
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = n - 1;
    n = points.size();
    vector<unordered_map<int, int>> dp(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        ans += (tr - tl);
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        int lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        if (lpos1 != -1)
            dp[i][tl] = min(dp[i + 1][ntl] + abs(tr - lpos2) + abs(ntl - lpos2),
                            dp[i + 1][ntl] + abs(tr - lpos1) + abs(ntl - lpos1));
        else
            dp[i][tl] = dp[i + 1][ntl] + abs(tr - lpos2) + abs(ntl - lpos2);

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i + 1][ntr] + abs(tl - rpos2) + abs(ntr - rpos2),
                            dp[i + 1][ntr] + abs(tl - rpos1) + abs(ntr - rpos1));
        else
            dp[i][tr] = dp[i + 1][ntr] + abs(tl - rpos2) + abs(ntr - rpos2);

    }
    cout << ans + dp[0][0] + abs(points.back().front() - points.back().back());
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e18;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    a[0].emplace_back(0);
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    cout << ans + res[0][0];
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e18;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    a[0].emplace_back(0);
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n), res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            res[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            res[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], res[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            res[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            res[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], res[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;

        res[i][tl] = dp[i][tr] + (tr - tl);
        res[i][tr] = dp[i][tl] + (tr - tl);
    }
    ans += abs(points.back().front() - points.back().back());
    if (n != 1)
        cout << ans + res[0][0];
    else
        cout << ((ups.front() <= points.back().front()) ? ans : ans - 2 * (points.back().front() - ups.front()));
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        ans += (tr - tl);
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        int lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        if (lpos1 != -1)
            dp[i][tl] = min(dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2),
                            dp[i + 1][ntr] + abs(tr - lpos1) + abs(ntr - lpos1));
        else
            dp[i][tl] = dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2);

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2),
                            dp[i + 1][ntl] + abs(tl - rpos1) + abs(ntl - rpos1));
        else
            dp[i][tr] = dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2);

    }
    cout << ans + dp[0][0] + abs(points.back().front() - points.back().back());
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n);
    for (int i = 0; i < n - 1; ++i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(dp[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            dp[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], dp[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));

        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(dp[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            dp[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], dp[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(dp[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            dp[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], dp[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(dp[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            dp[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], dp[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
    }
    ans += abs(points.back().front() - points.back().back());
    vector<unordered_map<int, int>> res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        res[i][tl] = dp[i][tr] + (tr - tl) + res[i + 1][ntl];
        res[i][tr] = dp[i][tl] + (tr - tl) + res[i + 1][ntr];
    }
    cout << ans + res[0][0];
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        ans += (tr - tl);
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;
        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        if (lpos1 != -1)
            dp[i][tl] = min(dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2),
                            dp[i + 1][ntr] + abs(tr - lpos1) + abs(ntr - lpos1));
        else
            dp[i][tl] = dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2);

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2),
                            dp[i + 1][ntl] + abs(tl - rpos1) + abs(ntl - rpos1));
        else
            dp[i][tr] = dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2);

    }
    cout << ans + dp[0][0] + abs(points.back().front() - points.back().back());
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = n - 1;
    n = points.size();
    vector<unordered_map<int, int>> dp(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        ans += (tr - tl);
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        int lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        if (lpos1 != -1)
            dp[i][tl] = min(dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2),
                            dp[i + 1][ntr] + abs(tr - lpos1) + abs(ntr - lpos1));
        else
            dp[i][tl] = dp[i + 1][ntr] + abs(tr - lpos2) + abs(ntr - lpos2);

        if (rpos1 != -1)
            dp[i][tr] = min(dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2),
                            dp[i + 1][ntl] + abs(tl - rpos1) + abs(ntl - rpos1));
        else
            dp[i][tr] = dp[i + 1][ntl] + abs(tl - rpos2) + abs(ntl - rpos2);

    }
    cout << ans + dp[0][0] + abs(points.back().front() - points.back().back());
    return 0;
}


#ifdef MY_DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long
typedef long long ll;
using namespace std;

const int INF = 1e9;

signed main() {
#ifdef MY_DEBUG
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("movetofront.in", "r", stdin);
    //freopen("movetofront.out", "w", stdout);
#endif
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    map<int, vector<int>> a;
    int tmax = 0;
    for (int i = 0; i < k; ++i) {
        int x, y;
        cin >> x >> y, x--, y--;
        tmax = max(tmax, x);
        a[x].emplace_back(y);
    }
    vector<int> ups(q);
    for (int &i : ups)
        cin >> i, i--;
    vector<vector<int>> points;
    for (auto &i : a) {
        points.emplace_back(i.second);
    }
    points[0].emplace_back(0);
    sort(ups.begin(), ups.end());
    for (auto &i : points)
        sort(i.begin(), i.end());
    int ans = tmax;
    n = points.size();
    vector<unordered_map<int, int>> dp(n), pr(n);
    for (int i = 0; i < n - 1; ++i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        int rpos1, rpos2, lpos1, lpos2;

        if (lower_bound(ups.begin(), ups.end(), ntr) != ups.end())
            rpos2 = *lower_bound(ups.begin(), ups.end(), ntr), rpos1 = -1;
        else
            rpos2 = ups.back(), rpos1 = -1;
        if (rpos2 != ups.front())
            rpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntr));

        if (lower_bound(ups.begin(), ups.end(), ntl) != ups.end())
            lpos2 = *lower_bound(ups.begin(), ups.end(), ntl), lpos1 = -1;
        else
            lpos2 = ups.back(), lpos1 = -1;

        if (lpos2 != ups.front())
            lpos1 = *prev(lower_bound(ups.begin(), ups.end(), ntl));

        dp[i][tr] = dp[i][tl] = INF;
        pr[i][tl] = ntr;
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(dp[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2),
                            dp[i + 1][ntr] + abs(tl - lpos1) + abs(ntr - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], dp[i + 1][ntr] + abs(tl - lpos2) + abs(ntr - lpos2));
        int t = dp[i][tl];
        if (lpos1 != -1)
            dp[i][tl] = min(dp[i][tl], min(dp[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2),
                            dp[i + 1][ntl] + abs(tl - lpos1) + abs(ntl - lpos1)));
        else
            dp[i][tl] = min(dp[i][tl], dp[i + 1][ntl] + abs(tl - lpos2) + abs(ntl - lpos2));
        if (t != dp[i][tl])
            pr[i][tl] = ntl;

        pr[i][tr] = ntl;
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(dp[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2),
                            dp[i + 1][ntl] + abs(tr - rpos1) + abs(ntl - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], dp[i + 1][ntl] + abs(tr - rpos2) + abs(ntl - rpos2));
        t = dp[i][tr];
        if (rpos1 != -1)
            dp[i][tr] = min(dp[i][tr], min(dp[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2),
                            dp[i + 1][ntr] + abs(tr - rpos1) + abs(ntr - rpos1)));
        else
            dp[i][tr] = min(dp[i][tr], dp[i + 1][ntr] + abs(tr - rpos2) + abs(ntr - rpos2));
        if (t != dp[i][tr])
            pr[i][tr] = ntr;
    }
    ans += abs(points.back().front() - points.back().back());
    vector<unordered_map<int, int>> res(n);
    for (int i = n - 2; i >= 0; --i) {
        int tl = points[i].front(), tr = points[i].back();
        int ntl = points[i + 1].front(), ntr = points[i + 1].back();
        res[i][tl] = dp[i][tr] + (tr - tl) + res[i + 1][pr[i][tr]];
        res[i][tr] = dp[i][tl] + (tr - tl) + res[i + 1][pr[i][tl]];
    }
    cout << ans + res[0][0];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(1,mn-1),ss=search2(mx+1, n);
    ll ans;
    if(ff>0)ans=mx+mn-2*ff;
    if(ss<=n)ans=Min(ans,2*ss-mx-mn);
    return ans;
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,r);
        d[1][1]=d[0][0]+r-l+dist(l_,l);
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(0,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,r);
        d[1][1]=d[0][0]+r-l+dist(l_,l);
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll lft[200005],rgt[200005];
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    if(rgt[mn]<=mx)return mx-mn;
    return Min(mn+mx-2*lft[mn],2*rgt[mx]-(mn+mx));
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    ll num=1e18;
    for(int i=m;i>=1;i--){
        if(b[i]==1) num=i;
        rgt[i]=num;
    }
    num=-1e18;
    for(int i=1;i<=m;i++){
        if(b[i]==1)num=i;
        lft[i]=num;
    }
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=Min(d[0][1]+r-l+dist(r_,r),d[0][0]+r-l+dist(l_,r));
        d[1][1]=Min(d[0][1]+r-l+dist(r_,l),d[0][0]+r-l+dist(l_,l));
        d[0][1]=Min(d[1][1],d[1][0]+r-l);
        d[0][0]=Min(d[1][0],d[1][1]+r-l);
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);

    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(1,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=Min(d[0][1]+r-l+dist(r_,r),d[0][0]+r-l+dist(l_,r));
        d[1][1]=Min(d[0][1]+r-l+dist(r_,l),d[0][0]+r-l+dist(l_,l));
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(1,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,r);
        d[1][1]=d[0][0]+r-l+dist(l_,l);
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(0,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,r);
        d[1][1]=d[0][0]+r-l+dist(l_,l);
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(1,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=Min(d[0][1]+r-l+dist(r_,r),d[0][0]+r-l+dist(l_,r));
        d[1][1]=Min(d[0][1]+r-l+dist(r_,l),d[0][0]+r-l+dist(l_,l));
        d[0][1]=Min(d[1][1],d[1][0]+r-l);
        d[0][0]=Min(d[1][0],d[1][1]+r-l);
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(1,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,r);
        d[1][1]=d[0][0]+r-l+dist(l_,l);
        d[0][1]=Min(d[1][1],d[1][0]+r-l);
        d[0][0]=Min(d[1][0],d[1][1]+r-l);
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include<bits/stdc++.h>
using namespace std;
#define PI acos(–1)
#define F first
#define S second
#define PB push_back
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
ll Min(ll a,ll b){return (a<b)?a:b;}
ll Max(ll a,ll b){return (a>b)?a:b;}
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
// @@@ don’t touch or edit @@@
ll a[200005][2],b[200005];
ll ch[200005];
ll d[2][2];
ll n,m;
ll search1(ll s,ll e){
    ll ans=-1;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Max(ans,mid);
            s=mid+1;
        }
        else e=mid-1;
    }
    return ans;
}
ll search2(ll s,ll e){
    ll ans=1e18;
    while(s<=e){
        ll mid=(s+e)/2;
        if(b[e]-b[s-1]>0){
            ans=Min(ans,mid);
            e=mid-1;
        }
        else s=mid+1;
    }
    return ans;
}
ll dist(ll pre,ll nxt){
    ll mn=Min(pre,nxt);
    ll mx=Max(pre,nxt);
    // (1~mn-1),(mn~mx),(mx+1~n);
    if(b[mx]-b[mn-1]>0){
        return mx-mn;
    }
    ll ff=search1(0,mn-1),ss=search2(mx+1, n);
    return Min(mn-ff+mx-ff,ss-mn+ss-mx);
}
int main(){
    F_I
    ll k,q;
    cin>>n>>m>>k>>q;
    ch[1]=1;
    for(int i=1;i<=n;i++)a[i][0]=1e18,a[i][1]=0;
    a[1][0]=a[1][1]=1;
    ll mx=1;
    for(int i=0;i<k;i++){
        ll x,y;
        cin>>x>>y;
        a[x][0]=Min(a[x][0],y);
        a[x][1]=Max(a[x][1],y);
        ch[x]=1;
        mx=Max(mx,x);
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        b[x]=1;
    }
    for(int i=1;i<=m;i++) b[i]+=b[i-1];
    ll l_=1,r_=a[1][1];
    d[0][0]=2*(r_-l_);
    d[0][1]=r_-l_;

    for(int i=2;i<=mx;i++){
        if(ch[i]==0)continue;
        ll l=a[i][0],r=a[i][1];
        d[1][0]=d[0][1]+r-l+dist(r_,l);
        d[1][1]=d[0][0]+r-l+dist(l_,r);
        d[0][1]=d[1][1];
        d[0][0]=d[1][0];
        l_=l,r_=r;
    }
    cout<<Min(d[0][0],d[0][1])+(mx-1);
    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
int dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
int main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, n);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1];
			dp[i][0] = dp[i - 1][0];
		}
	}
	cout << min(dp[n][1], dp[n][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
int dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
int main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[n][1], dp[n][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
ll dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
signed main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, n) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_r = getdis(r[last], 1, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int r_l_l = getdis(r[last], 0, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_l = getdis(l[last], 0, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			int l_r_r = getdis(l[last], 1, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(min(l_l_r, l_r_r) + dp[i - 1][0], min(r_l_r,r_r_r) + dp[i - 1][1]);
			dp[i][0] = min(min(r_r_l, r_l_l) + dp[i - 1][1], min(l_r_l, l_l_l) + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][0] = dp[i-1][0];
			dp[i][1] = dp[i-1][1];
		}
	}
	cout << min(dp[nn][1], dp[nn][0]) + nn - 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
int dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
int main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[nn][1], dp[nn][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
int dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
int main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, n);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[n][1], dp[n][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
ll dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
signed main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[nn][1], dp[nn][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
ll dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
signed main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		// dp[1][1] = r[1] - 1;
		// dp[1][0] = dp[1][1] + r[1] - l[1];
		dp[1][1] = dp[1][0] = r[1] - 1;
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(l_l_r + dp[i - 1][0], r_l_r + dp[i - 1][1]);
			dp[i][0] = min(r_r_l + dp[i - 1][1], l_r_l + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[nn][1], dp[nn][0]) << endl;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define LL long long
#define ULL unsigned long long
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define dep(i,j,k) for(int i=k;i>=j;i--)
#define INF 0x3f3f3f3f3f3f3f3f
#define mem(i,j) memset(i,j,sizeof(i))
#define make(i,j) make_pair(i,j)
#define pb push_back
#define Pi acos(-1.0)
using namespace std;
const int N = 2e5 + 5;
LL l[N], r[N], s[N];
int main() {
    int n, m, k, q;
    while(~scanf("%d %d %d %d", &n, &m, &k, &q)) {
        rep(i, 1, n) l[i] = INF, r[i] = 0;
        LL Y = 0;
        rep(i, 1, k) {
            LL x, y;
            scanf("%lld %lld", &x, &y);
            Y = max(Y, x);
            l[x] = min(l[x], y);
            r[x] = max(r[x], y);
        }
        rep(i, 1, q) scanf("%lld", &s[i]);
        sort(s + 1, s + 1 + q);
        LL ansl, ansr;
        LL L = l[1], R = r[1];
        if(r[1] == 0) ansl = 0, ansr = 0, L = R = 1;
        else ansl = r[1] - 1 + r[1] - l[1], ansr = r[1] - 1;
        rep(i, 2, n) if(r[i]) {

            int indexl = lower_bound(s + 1, s + 1 + q, L) - s;
            int indexr = lower_bound(s + 1, s + 1 + q, R) - s;

            int Ll, Lr, Rl, Rr;  Ll = Lr = Rl = Rr = INF;
            if(indexl <= q) Lr = s[indexl]; if(indexl > 1) Ll = s[indexl - 1];
            if(indexr <= q) Rr = s[indexr]; if(indexr > 1) Rl = s[indexr - 1];

            LL nowL = INF, nowR = INF;

            nowL = min(nowL, ansl + abs(L - Ll) + abs(Ll - r[i]) + abs(r[i] - l[i])); ///L -> Ll -> r[i] -> l[i]
            nowL = min(nowL, ansl + abs(L - Lr) + abs(Lr - r[i]) + abs(r[i] - l[i])); ///L -> Lr -> r[i] -> l[i]
            nowL = min(nowL, ansr + abs(R - Rl) + abs(Rl - r[i]) + abs(r[i] - l[i])); ///R -> Rl -> r[i] -> l[i]
            nowL = min(nowL, ansr + abs(R - Rr) + abs(Rr - r[i]) + abs(r[i] - l[i])); ///R -> Rr -> r[i] -> l[i]

            nowR = min(nowR, ansl + abs(L - Ll) + abs(Ll - l[i]) + abs(l[i] - r[i])); ///L -> Ll -> l[i] -> r[i]
            nowR = min(nowR, ansl + abs(L - Lr) + abs(Lr - l[i]) + abs(l[i] - r[i])); ///L -> Lr -> l[i] -> r[i]
            nowR = min(nowR, ansr + abs(R - Rl) + abs(Rl - l[i]) + abs(l[i] - r[i])); ///R -> Rl -> l[i] -> r[i]
            nowR = min(nowR, ansr + abs(R - Rr) + abs(Rr - l[i]) + abs(l[i] - r[i])); ///R -> Rr -> l[i] -> r[i]

            ansl = nowL, ansr = nowR; L = l[i], R = r[i];
        }
        printf("%lld\n", min(ansl, ansr) + Y - 1);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
int dp[maxn][2];
vector<int> safecol;
int nxt(){
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last){//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way? abs(rout[last_pos] - last_pos):abs(lout[last_pos] - last_pos));
	ret += (end? (way ? abs(l[cur] - rout[last_pos]) :abs(l[cur] - lout[last_pos])):(way?abs(rout[last_pos] - r[cur]) :abs(lout[last_pos] - r[cur])));
	return ret;
}
int main(){
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	_rep(i, 1, k){
		int x = nxt(), y = nxt();
		if(l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q){
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m+1);
	sort(all(safecol));
	_rep(i, 1, m){
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if(lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if(rout[i] == safecol[q+1])//右边无出口
			rout[i] = safecol[q];
	}
	if(l[1]){
		dp[1][0] = dp[1][1] = r[1] - 1;
	}
    int last = 1;
	_rep(i, 2, n){
		if(l[i]){
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			dp[i][1] = min(l_l_r + dp[i-1][0], r_l_r + dp[i-1][1]);
			dp[i][0] = min(r_r_l + dp[i-1][1], l_r_l + dp[i-1][0]);
			last = i;
		}else {
            dp[i][1]++;
            dp[i][0]++;
        }
	}
    cout << min(dp[n][1], dp[n][0]) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (int i = (a); i >= (b); --i)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rof(i, a, b) for (int i = (a); i > (b); --i)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << "s" << endl;
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int maxn = 2e5 + 10;
int n, m, k, q;
int l[maxn], r[maxn], lout[maxn], rout[maxn];
ll dp[maxn][2];
vector<int> safecol;
int nxt() {
	int ret;
	scanf("%d", &ret);
	return ret;
}
int getdis(int last_pos, int way, int end, int cur, int last) {//way=0走左路,end=0从右到左
	int ret = 1 + r[cur] - l[cur];
	ret += (way ? abs(rout[last_pos] - last_pos) : abs(lout[last_pos] - last_pos));
	ret += (end ? (way ? abs(l[cur] - rout[last_pos]) : abs(l[cur] - lout[last_pos])) : (way ? abs(rout[last_pos] - r[cur]) : abs(lout[last_pos] - r[cur])));
	return ret;
}
signed main() {
	n = nxt(), m = nxt(), k = nxt(), q = nxt();
	int nn = 0;
	_rep(i, 1, k) {
		int x = nxt(), y = nxt();
		nn = max(x, nn);
		if (l[x] == 0)l[x] = y, r[x] = y;
		else l[x] = min(l[x], y), r[x] = max(r[x], y);
	}
	_rep(i, 1, q) {
		int tmp = nxt();
		safecol.push_back(tmp);
	}
	safecol.push_back(0), safecol.push_back(m + 1);
	sort(all(safecol));
	_rep(i, 1, m) {
		lout[i] = safecol[upper_bound(safecol.begin(), safecol.end(), i) - safecol.begin() - 1];
		rout[i] = safecol[lower_bound(safecol.begin(), safecol.end(), i) - safecol.begin()];
		if (lout[i] == safecol[0])//左边无出口
			lout[i] = safecol[1];
		else if (rout[i] == safecol[q + 1])//右边无出口
			rout[i] = safecol[q];
	}
	if (l[1]) {
		dp[1][1] = r[1] - 1;
		dp[1][0] = dp[1][1] + r[1] - l[1];
	}
	int last = 1;
	_rep(i, 2, nn) {
		if (l[i]) {
			int r_l_r = getdis(r[last], 0, 1, i, last);
			int r_r_r = getdis(r[last], 1, 1, i, last);
			int r_r_l = getdis(r[last], 1, 0, i, last);
			int r_l_l = getdis(r[last], 0, 0, i, last);
			int l_r_l = getdis(l[last], 1, 0, i, last);
			int l_l_l = getdis(l[last], 0, 0, i, last);
			int l_l_r = getdis(l[last], 0, 1, i, last);
			int l_r_r = getdis(l[last], 1, 1, i, last);
			//if (i == 2)l_r_l += r[1] - l[1], l_l_r += r[1] - l[1];
			dp[i][1] = min(min(l_l_r, l_r_r) + dp[i - 1][0], min(r_l_r,r_r_r) + dp[i - 1][1]);
			dp[i][0] = min(min(r_r_l, r_l_l) + dp[i - 1][1], min(l_r_l, l_l_l) + dp[i - 1][0]);
			last = i;
		}
		else {
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][0] = dp[i - 1][0] + 1;
		}
	}
	cout << min(dp[nn][1], dp[nn][0]) << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1[0] = 1ULL<<60; moves1[1] = 1ULL<<60;
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				for (auto it2 = max(safe.begin(), it-1); it2 < min(it+1, safe.end()); it2++) {
					uint v = *it2;
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (pos[j]-v) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	vector<uint> vs;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1[0] = 1ULL<<60; moves1[1] = 1ULL<<60;
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				vs.clear();
				if (it != safe.end()) { vs.push_back(*it); }
				if (it != safe.begin()) { vs.push_back(*(it-1)); }
				for (uint k = 0; k < 2; k++) {
					for (auto v : vs) {
						upmin(moves1[k], moves[j] + diff(pos[j],v) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1 = {1ULL<<60, 1ULL<<60};
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				if (it != safe.begin()) {
					uint v = *(it-1);
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (pos[j]-v) + diff(v,pos1[k]));
					}
				}
				if (it != safe.end()) {
					uint v = *it;
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (v-pos[j]) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].first;
	array<uint,2> pos = {tr[0].first, tr[0].first}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1 = {1ULL<<60, 1ULL<<60};
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				if (it != safe.begin()) {
					uint v = *(it-1);
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (pos[j]-v) + diff(v,pos1[k]));
					}
				}
				if (it != safe.end()) {
					uint v = *it;
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (v-pos[j]) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			swap(moves, moves1);
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	cerr << pos[0] << ' ' << pos[1] << ' ' << moves[0] << ' ' << moves[1] << '\n';
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1 = {1ULL<<60, 1ULL<<60};
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				if (it != safe.begin()) {
					uint v = *(it-1);
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (pos[j]-v) + diff(v,pos1[k]));
					}
				}
				if (it != safe.end()) {
					uint v = *it;
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (v-pos[j]) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
	cerr << pos[0] << ' ' << pos[1] << ' ' << moves[0] << ' ' << moves[1] << '\n';
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1[0] = 1ULL<<60; moves1[1] = 1ULL<<60;
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				if (it != safe.begin()) {
					uint v = *(it-1);
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (pos[j]-v) + diff(v,pos1[k]));
					}
				}
				if (it != safe.end()) {
					uint v = *it;
					for (uint k = 0; k < 2; k++) {
						upmin(moves1[k], moves[j] + (v-pos[j]) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

void upmin(ull &x, ull y) {
	if (x > y) { x = y; }
}

uint diff(uint x, uint y) {
	if (x <= y) { return y-x; }
	else { return x-y; }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	uint n, m, k, q;
	cin >> n >> m >> k >> q;
	uint maxr = 0;
	vector<pair<uint,uint>> tr(n, {m, 0});
	while(k--) {
		uint r, c;
		cin >> r >> c;
		r--; c--;
		maxr = max(maxr, r);
		tr[r].first = min(tr[r].first, c);
		tr[r].second = max(tr[r].second, c);
	}
	vector<uint> safe(q);
	for (auto& v : safe) {
		cin >> v;
		v--;
	}
	sort(safe.begin(), safe.end());

	ull ans = maxr + tr[0].second;
	array<uint,2> pos = {tr[0].second, tr[0].second}, pos1;
	array<ull,2> moves = {0, 0}, moves1;
	vector<uint> vs;
	for (uint i = 1; i < n; i++) {
		if (tr[i].first < m) {
			pos1[0] = tr[i].first; pos1[1] = tr[i].second;
			ans += pos1[1] - pos1[0];
			moves1[0] = 1ULL<<60; moves1[1] = 1ULL<<60;
			for (uint j = 0; j < 2; j++) {
				auto it = lower_bound(safe.begin(), safe.end(), pos[j]);
				vs.clear();
				if (it != safe.end()) { vs.push_back(*it); }
				if (it != safe.begin()) { vs.push_back(*(it-1)); }
				for (uint k = 0; k < 2; k++) {
					for (auto v : vs) {
						upmin(moves1[k], moves[j] + diff(pos[j],v) + diff(v,pos1[k]));
					}
				}
			}
			swap(pos, pos1);
			moves[0] = moves1[1]; moves[1] = moves1[0];
			cerr << moves[0] << ' ' << moves[1] << endl;
		}
	}
	cout << ans + min(moves[0], moves[1]) << endl;
	return 0;
}