#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T, class S>
ostream &operator<<(ostream &o, const pair<T, S> &p) {
  return o << '(' << p.first << ", " << p.second << ')';
}
template <template <class, class...> class T, class... A>
typename enable_if<!is_same<T<A...>, string>(), ostream &>::type operator<<(
    ostream &o, T<A...> V) {
  o << '[';
  for (auto a : V) o << a << ", ";
  return o << ']';
}
vector<pair<long long int, long long int> > events;
pair<long long int, pair<long long int, long long int> > qs[1000010];
long long int id = 0, t[2 * 1000010];
long long int f(long long int a, long long int b) { return a + b; }
void modify(long long int p, long long int value) {
  for (t[p += 1000010] += value; p /= 2;) t[p] = f(t[2 * p], t[2 * p + 1]);
}
long long int query(long long int l, long long int r) {
  long long int resl = id, resr = id;
  for (l += 1000010, r += 1000010; l < r; l /= 2, r /= 2) {
    if (l & 1) resl = f(resl, t[l++]);
    if (r & 1) resr = f(t[--r], resr);
  }
  return f(resl, resr);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n;
  cin >> n;
  long long int m;
  cin >> m;
  long long int ans = 1;
  for (long long int i = 0; i < n; i++) {
    long long int y;
    cin >> y;
    long long int l;
    cin >> l;
    long long int r;
    cin >> r;
    if (!l && r == 1000000) ans++;
    events.emplace_back(l, y);
    events.emplace_back(r, -y);
  }
  sort((events).begin(), (events).end());
  long long int idx = 0;
  for (long long int i = 0; i < m; i++)
    cin >> qs[i].first >> qs[i].second.first >> qs[i].second.second;
  sort(qs, qs + m);
  for (long long int i = 0; i < m; i++) {
    if (!qs[i].second.first && qs[i].second.second == 1000000) ans++;
    vector<long long int> temp;
    while (idx < events.size() && events[idx].first <= qs[i].first) {
      if (events[idx].second > 0)
        modify(events[idx].second, 1);
      else if (events[idx].first == qs[i].first)
        temp.push_back(-events[idx].second);
      else
        modify(-events[idx].second, -1);
      idx++;
    }
    ans += query(qs[i].second.first, qs[i].second.second + 1);
    for (long long int x : temp) modify(x, -1);
  }
  cout << ans << '\n';
}
