#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long long x1, x2, y;
} x_line;
typedef struct {
  long long x, y1, y2;
} y_line;
void append_unique(vector<long long>* v, long long val) {
  if ((find((*v).begin(), (*v).end(), val) == (*v).end())) {
    v->push_back(val);
  }
}
int index(vector<long long>* v, long long val) {
  return (find((*v).begin(), (*v).end(), val) - (*v).begin());
}
x_line xl[2000];
y_line yl[2000];
int grid[6001][6001] = {};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<long long> x_axis, y_axis;
  append_unique(&x_axis, 0);
  append_unique(&y_axis, 0);
  for (int i = 0; i < n; i++) {
    cin >> xl[i].x1 >> xl[i].x2 >> xl[i].y;
    append_unique(&x_axis, xl[i].x1);
    append_unique(&x_axis, xl[i].x2);
    append_unique(&y_axis, xl[i].y);
  }
  for (int i = 0; i < m; i++) {
    cin >> yl[i].x >> yl[i].y1 >> yl[i].y2;
    append_unique(&x_axis, yl[i].x);
    append_unique(&y_axis, yl[i].y1);
    append_unique(&y_axis, yl[i].y2);
  }
  sort(x_axis.begin(), x_axis.end());
  sort(y_axis.begin(), y_axis.end());
  for (int i = 0; i < n; i++) {
    int y = index(&y_axis, xl[i].y) * 2;
    int x_begin = index(&x_axis, xl[i].x1) * 2;
    int x_end = index(&x_axis, xl[i].x2) * 2;
    for (int x = x_begin; x <= x_end; x++) {
      grid[x][y] = -1;
    }
  }
  for (int i = 0; i < m; i++) {
    int x = index(&x_axis, yl[i].x) * 2;
    int y_begin = index(&y_axis, yl[i].y1) * 2;
    int y_end = index(&y_axis, yl[i].y2) * 2;
    for (int y = y_begin; y <= y_end; y++) {
      grid[x][y] = -1;
    }
  }
  queue<pair<int, int>> q;
  pair<int, int> rs[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  bool out_of_bound = false;
  q.push(make_pair(index(&x_axis, 0) * 2, index(&y_axis, 0) * 2));
  grid[index(&x_axis, 0) * 2][index(&y_axis, 0) * 2] = 1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    for (auto r : rs) {
      int x = p.first + r.first;
      int y = p.second + r.second;
      if (x < 0 || y < 0 || x >= 2 * x_axis.size() - 2 ||
          y >= 2 * y_axis.size() - 2) {
        out_of_bound = true;
        break;
      }
      if (grid[x][y] == 0) {
        grid[x][y] = 1;
        q.push(make_pair(x, y));
      }
    }
    if (out_of_bound) break;
  }
  if (out_of_bound) {
    cout << "INF" << endl;
  } else {
    long long area = 0;
    for (int x = 0; x < x_axis.size() - 1; x++) {
      for (int y = 0; y < y_axis.size() - 1; y++) {
        area += grid[2 * x + 1][2 * y + 1] * (x_axis[x + 1] - x_axis[x]) *
                (y_axis[y + 1] - y_axis[y]);
      }
    }
    cout << area << endl;
  }
}
int main() {
  solve();
  return 0;
}
