//switch between terminal and editor: ctrl + ` 
#include"bits/stdc++.h"
#define endl '\n'
using namespace std;
typedef long long ll;
// #define comparator_datatype pair<int,pair<ll,ll>> 
#define loop(i,x,n,u) for(ll i = x;i < n;i+=u)
#define rloop(i,x,n,u) for(ll i = x;i > n;i-=u)
#define mod 1000000007
#define read(X,n) loop(i,0,n,1){cin>>X[i];}

void compressArray(vector<ll>& array){
  map<ll,int> rank_;
  for(auto& i:array){
    rank_[i] = 1;
  }
  int r = 1;
  for(auto& i:rank_){
    i.second = r++;
  }
  loop(i,0,array.size(),1){
    array[i] = rank_[array[i]];
  }
}

//void solve(){}
int main(){
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  int t = 1;
  //cin>>t;
  while(t--){
    //solve();
    int n,type;
    cin>>n;
    vector<pair<double,double>> arr(n);
    loop(i,0,n,1){
      cin>>type>>arr[i].first>>arr[i].second;
      if(type==2)
        arr[i].second-=0.1;
      else if(type==3)
        arr[i].first+=0.1;
      else if(type==4){
        arr[i].first+=0.1,arr[i].second-=0.1;
      }
    }
    // for(auto& i:arr)
    //   cout<<i.first<<" "<<i.second<<endl;
    ll count = 0;
    loop(i,0,n,1){
      loop(j,i+1,n,1){
        if((arr[i].second < arr[j].first) || (arr[i].first > arr[j].second))
          continue;
        else{
          count++;
          // cout<<arr[i].first<<":"<<arr[i].second<<" "<<arr[j].first<<":"<<arr[j].second<<endl;
        }
      }
    }
    cout<<count<<endl;
  }
  return 0;
}
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//#define ENVIRONMENT_LINKED_BOOST

#ifdef ENVIRONMENT_LINKED_BOOST
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
#endif

using namespace std;
using uint = unsigned int;
using ll   = long long;
using ull  = unsigned long long;
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define ALL(v)       v.begin(), v.end()

template <typename A, typename B>
void chmin(A &a, const B &b) {
    a = min(a, static_cast<A>(b));
};
template <typename A, typename B>
void chmax(A &a, const B &b) {
    a = max(a, static_cast<A>(b));
};

ll solve(const vector<pair<ll, ll>> &V, multiset<ll> S) {
    ll ans = 0;
    REP(i, 0, V.size()) {
        auto it = S.lower_bound(V[i].second);
        if (it == S.end()) continue;
        ans += V[i].first;
        S.erase(it);
    }
    return ans;
}

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<pair<ll, ll>> V(N);
    REP(i, 0, N) {
        cin >> V[i].second >> V[i].first;
    }
    sort(V.begin(), V.end(), greater<pair<ll, ll>>());
    vector<ll> s(M);
    REP(i, 0, M)
    cin >> s[i];
    REP(q, 0, Q) {
        ll l, r;
        cin >> l >> r;
        --l;
        --r;
        multiset<ll> S;
        REP(i, 0, l)
        S.insert(s[i]);
        REP(i, r + 1, M)
        S.insert(s[i]);
        cout << solve(V, S) << endl;
    }
    return 0;
}
