import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException{
int N,M,B,G,i,x,y,j,k,result;
String[] str;
str = br.readLine().split(" ");
N = Integer.parseInt(str[0]);
M = Integer.parseInt(str[1]);
B = Integer.parseInt(str[2]);
G = Integer.parseInt(str[3]);
result = 0;
boolean[] line = new boolean[N+1];
boolean[] column = new boolean[M+1];
for(i = 0 ; i < B ; i++){
str = br.readLine().split(" ");
x = Integer.parseInt(str[0]);
y = Integer.parseInt(str[1]);
for(j = x ; j <= y ; j++){
line[j] = true;
}
}
for(i = 0 ; i < G ; i++){
str = br.readLine().split(" ");
x = Integer.parseInt(str[0]);
y = Integer.parseInt(str[1]);
for(j = x ; j <= y ; j++){
column[j] = true;
}
}
for(i = 1 ; i <= N ; i++){
if(!line[i]){
for(j = 1 ; j <= M ; j++){
if(!column[j]){
result++;
}
}
}
}
result = N * M - result;
out.write(result + "");
out.flush();
out.close();
br.close();
}
}
ps:用二维数组的话最后两个测试点会超时,所以用两个一维数组来分别模拟行和列