#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>

using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define PRIME 1000000007
#define ADD(a, b) (((a) % PRIME + (b) % PRIME) % PRIME)
#define MUL(a, b) ((((a) % PRIME) * ((b) % PRIME)) % PRIME)
#define SUB(a, b) (((a) % PRIME - (b) % PRIME + PRIME) % PRIME)
#define ll long long
#define FIND_VECTOR(v, i) find((v).begin(), (v).end(), i)
#define IS_UNIQUE(v, i) (FIND_VECTOR(v,i) == (v).end())
#define INDEX(v, i) (FIND_VECTOR(v, i) - (v).begin())

typedef struct {
	ll x1, x2, y;
} x_line;
typedef struct {
	ll x, y1, y2;
} y_line;

void append_unique(vector<ll>* v, ll val) {
	if (IS_UNIQUE(*v, val)) {
		v->push_back(val);
	}
}
int index(vector<ll>* v, ll val) {
	return INDEX(*v, val);
}
x_line xl[2000];
y_line yl[2000];
int grid[6001][6001] = {};

void solve() {
	int n, m; cin >> n >> m;
	vector<ll> x_axis, y_axis;
	append_unique(&x_axis, 0);
	append_unique(&y_axis, 0);

	REP(i, n) {
		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);
	}
	REP(i, m) {
		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());

	// grid[2x+1][2y+1]
	REP(i, n) {
		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;
		}
	}
	REP(i, m) {
		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;
		}
	}

	// search
	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 {
		ll 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;
}