#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=INT_MAX-500;

void mainmain(){
	int n,m;
	cin>>n>>m;
	vector<pii> v1(n);
	vint v2(m);
	vll odd,eve;
	rep(i,n){
		scanf("%d %d",&v1[i].F,&v1[i].S);
	}
	rep(i,m){
		scanf("%d",&v2[i]);
	}
	// v2.PB(INF);
	// v2.PB(-INF);
	sort(ALL(v2));
	ll todd=0,teve=0;
	rep(i,v2.size()){
		if(i==0);
		else if(i%2==1) todd+=v2[i]-v2[i-1];
		else teve+=v2[i]-v2[i-1];
		odd.PB(todd);
		eve.PB(teve);
	}
	// rep(i,odd.size()){
		// cout<<i<<" "<<odd[i]<<endl;
	// }
	// rep(i,odd.size()){
		// cout<<i<<" "<<eve[i]<<endl;
	// }
	// cout<<endl;
	ll ans=0;
	int tmp=ans;
	rep(i,n){
		// cout<<i<<","<<ans<<endl;
		if(v1[i].F<v1[i].S){
			auto it1=lower_bound(ALL(v2),v1[i].F);
			auto it2=lower_bound(ALL(v2),v1[i].S);
			if(it2==v2.begin()){
				ans+=v1[i].S-v1[i].F;
				continue;
			}
			it2--;
			if(it1==v2.end()){
				ans+=v1[i].S-v1[i].F;
				continue;
			}
			if(*it1==*it2){
				ans+=*it1-v1[i].F;
				continue;
			}
			if(*it2<*it1){
				ans+=v1[i].S-v1[i].F;
				continue;
			}
			int a=(int)(it1-v2.begin());
			int b=(int)(it2-v2.begin());
			// cout<<a<<" "<<b<<endl;
			if(a%2==1) ans+=odd[b]-odd[a];
			else ans+=eve[b]-eve[a];
			ans+=*it1-v1[i].F;
			if((b-a+1)%2==0) ans+=v1[i].S-*it2;
		}
		else{
			auto it1=lower_bound(ALL(v2),v1[i].F);
			auto it2=lower_bound(ALL(v2),v1[i].S);
			if(it1==v2.begin()){
				ans+=v1[i].F-v1[i].S;
				continue;
			}
			it1--;
			if(it2==v2.end()){
				ans+=v1[i].F-v1[i].S;
				continue;
			}
			if(*it1==*it2){
				ans+=v1[i].F-*it1;
				continue;
			}
			if(*it2>*it1){
				ans+=v1[i].F-v1[i].S;
				continue;
			}
			int a=(int)(it1-v2.begin());
			int b=(int)(it2-v2.begin());
			// cout<<a<<" "<<b<<endl;
			ans+=v1[i].F-*it1;
			if(a%2==0){
				ans+=odd[a]-odd[b];
			}
			else{
				ans+=eve[a]-eve[b];
			}
			if((b-a+1)%2==0) ans+=*it2-v1[i].S;
		}
	}
	cout<<ans<<endl;
}
/*
4
4
24+10
2
9
13+10
39

8
46
48
57
96

*/



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 4148