#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > vvx;   vector<pair<int, int> > vvz;   bool contained(int a, int b, int c, int d) {     if (c <= b && d >= a)       return true;     else       return false;   }   int main() {     int p, q, l, r;     cin >> p >> q >> l >> r;     vvx.resize(p + 1);     vvz.resize(q + 1);     for (int i = 0; i < p; i++) {       cin >> vvx[i].first >> vvx[i].second;     }     for (int i = 0; i < q; i++) {       cin >> vvz[i].first >> vvz[i].second;     }     int res = 0;     bool ok = false;     for (int i = l; i <= r; i++) {       ok = false;       for (int j = 0; j < p; j++) {         if (ok) {           ok = false;           break;         }         for (int k = 0; k < q; k++) {           if (contained(vvx[j].first, vvx[j].second, vvz[k].first + i,                         vvz[k].second + i)) {             ok = true;             res++;             break;           }         }       }     }     cout << res;     return 0;   }   