func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int M = 0x3f3f3f3f;   long long n, m, k, q, h;   int ld[N], rd[N];   vector<long long> p;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n >> m >> k >> q;     vector<vector<long long> > vec(n + 1);     memset(ld, 0x3f, sizeof(ld));     memset(rd, 0x3f, sizeof(rd));     while (k--) {       int x, y;       cin >> x >> y;       vec[x].push_back(y);     }     int f = !vec[1].empty();     vector<vector<long long> > tp = move(vec);     for (int i = 1; i <= n; ++i)       if (!tp[i].empty()) {         h = i;         sort(tp[i].begin(), tp[i].end());         vec.push_back(tp[i]);       }     long long l = (vec[0].back() << 1) - vec[0][0] - 1, r = vec[0].back() - 1,               lp = vec[0][0], rp = vec[0].back();     while (q--) {       int pos;       cin >> pos;       p.push_back(pos);     }     sort(p.begin(), p.end());     for (int i = 1; i <= m; ++i) {       auto tmp = lower_bound(p.begin(), p.end(), i);       if (tmp != p.end())         rd[i] = *tmp - i;       else         rd[i] = M;       tmp = upper_bound(p.begin(), p.end(), i);       if (tmp != p.begin())         ld[i] = i - *(tmp - 1);       else         ld[i] = M;     }     q = vec.size();     if (!f) l = r = rd[1], lp = rp = rd[1] + 1;     for (int i = f; i < q; ++i) {       vector<pair<long long, long long> > pos;       if (ld[lp] ^ M) pos.push_back(make_pair(lp - ld[lp], l + ld[lp]));       if (rd[lp] ^ M) pos.push_back(make_pair(lp + rd[lp], l + rd[lp]));       if (ld[rp] ^ M) pos.push_back(make_pair(rp - ld[rp], r + ld[rp]));       if (rd[rp] ^ M) pos.push_back(make_pair(rp + rd[rp], r + rd[rp]));       l = r = 1e18, lp = vec[i][0], rp = vec[i].back();       for (auto j : pos) {         if (j.first >= rp)           l = min(l, j.second + j.first - lp);         else           l = min(l, j.second + rp - j.first + rp - lp);         if (j.first <= lp)           r = min(r, j.second + rp - j.first);         else           r = min(r, j.second + j.first - lp + rp - lp);       }     }     cout << min(l, r) + h - 1;     return 0;   }   