#include <bits/stdc++.h>
using namespace std;
// t1
#define gc _getchar_nolock
#define pii pair<long long, long long>
using ll = long long;
using cd = complex<double>;
const ll maxN = 7e4 + 10, maxM = 64 + 10, MAX = 2e6 + 10;
//const ll maxScore = 4294967295;
const ll mod = 999999999999999989;
const double pi = acos(-1.0);
const double PI = acos(-1.0);
const double e = exp(1.0);
const ll naught = -100001;
const ll maxT = ceil(sqrt(maxN)) + 1;
const ll root_rec = 15311432;
const ll root_1 = 469870224;
const ll root_pw = (1 << 23);
const int K = 20;
const int g = 3;
const int LOGN = 20;
const int num1 = 16;
const int INF = 1e9;
//const ll is_query = -(1LL<<62)
template <typename T> void fastInt(T& angka) {
T kali = 1; angka = 0; char input = gc();
while (!isdigit(input)) { if (input == '-') kali = -1; input = gc(); }
while (isdigit(input)) angka = (angka << 3) + (angka << 1) + input - 48, input = gc();
angka *= kali;
}
void fastStr(string& str) {
str = "";
char c = '0';
while ((c = gc()) && (c != -1 && c != '\n' && c != '\t' && c != '\r' && c != ' ')) {
str += c;
}
}
ll powMod(ll x, ll y, ll p){
ll res = 1;
x %= p;
if(!x) return 0;
while (y > 0){
if (y & 1) res = ((res % p) * (x % p)) % p;
y = y >> 1;
x = ((x % p) * (x % p)) % p;
}
return res;
}
ll inverseMod(ll x, ll p){
return powMod(x, p - 2, p);
}
/*void upd(ll ind, ll l, ll r, ll i, ll val){
if(l > r) return;
if(i < l || r < i) return;
if(l == r){
assert(l == i);
seg[ind] = val;
return;
}
ll mid = (l + r) >> 1;
upd(ind << 1, l, mid, i, val);
upd(ind << 1 | 1, mid + 1, r, i, val);
seg[ind] = max(seg[ind << 1], seg[ind << 1 | 1]);
}
ll query(ll ind, ll l, ll r, ll tl, ll tr){
if(l > r) return 0;
if(tr < l || r < tl) return 0;
if(tl <= l && r <= tr) return seg[ind];
ll mid = (l + r) >> 1;
return max(query(ind << 1, l, mid, tl, tr), query(ind << 1 | 1, mid + 1, r, tl, tr));
}*/
void solve(){
ll n, q;
fastInt(n); fastInt(q);
vector<pii> arr(n);
vector<ll> uwu(n);
vector<pii> compr;
for(auto &x: arr){
fastInt(x.first);
fastInt(x.second);
}
ll r = arr[0].second, l = arr[0].first;
ll cnt = 0;
for(int i = 0; i < n; i++){
if(arr[i].first <= r){
r = max(r, arr[i].second);
uwu[i] = cnt;
}else{
cnt++;
uwu[i] = cnt;
compr.push_back({l, r});
l = arr[i].first;
r = arr[i].second;
}
}
compr.push_back({l, r});
vector<ll> dp(compr.size());
dp[0] = 0;
for(int i = 1; i < compr.size(); i++){
dp[i] = dp[i - 1] + compr[i].first - compr[i - 1].second;
//cout << dp[i] << " ";
}
//cout << endl;
vector<ll> que(q + 1);
que[0] = 1;
for(int i = 1; i < q + 1; i++){
fastInt(que[i]);
}
ll ans = 0;
for(int i = 0; i < q; i++){
int l = min(uwu[que[i] - 1], uwu[que[i + 1] - 1]);
int r = max(uwu[que[i] - 1], uwu[que[i + 1] - 1]);
//cout << l << " " << r << " " << que[i] << endl;
ans += dp[r] - dp[l];
}
cout << ans << '\n';
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.precision(10);
//auto beg = high_resolution_clock::now();
//cout << req(1e7 + 8) << '\n';
int t; t = 1;
while(t--) solve();
//auto en = high_resolution_clock::now();
//auto dur = duration_cast<microseconds>(en - beg);
//cout << dur.count() << endl;
return 0;
}