#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct Yoko {
	int l, r, y;
};

struct Tate {
	int u, d, x;
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> H >> W;
	vector<Tate>tate(H);
	vector<Yoko>yoko(W);
	map<int, int>xp;
	map<int, int>yp;
	xp[-MOD] = xp[MOD] = yp[-MOD] = yp[MOD]=xp[0]=yp[0]=0;
	for (int i = 0; i < H; i++) {
		cin >> tate[i].d >> tate[i].u >> tate[i].x;
		xp[tate[i].x] = 0;
		yp[tate[i].d] = 0;
		yp[tate[i].u] = 0;
	}
	for (int i = 0; i < W; i++) {
		cin >> yoko[i].y >> yoko[i].l >> yoko[i].r;
		xp[yoko[i].l] = 0;
		xp[yoko[i].r] = 0;
		yp[yoko[i].y] = 0;
	}
	int xcnt = 0;
	int ycnt = 0;
	vector<long long int>x;
	vector<long long int>y;
	for (auto &i : xp) {
		i.second = xcnt++;
		x.push_back(i.first);
	}
	for (auto &i : yp) {
		y.push_back(i.first);
		i.second = ycnt++;
	}
	for (auto &i : yoko) {
		i.l = xp[i.l];
		i.r = xp[i.r];
		i.y = yp[i.y];
	}
	for (auto &i : tate) {
		i.x = xp[i.x];
		i.d = yp[i.d];
		i.u = yp[i.u];
	}
	vector<vector<int>>visit(ycnt, vector<int>(xcnt));
	visit[yp.lower_bound(0)->second ][xp.lower_bound(0)->second] = 1;
	queue<pair<int, int>>Q;
	Q.emplace(yp.lower_bound(0)->second, xp.lower_bound(0)->second);
	vector<vector<int>>hline(ycnt, vector<int>(xcnt));
	for (auto i : yoko) {
//		cout <<"yline " << i.y << " " << i.l << " " << i.r << endl;
		hline[i.y][i.l]++;
		hline[i.y][i.r]--;
	}
	for (int i = 0; i < ycnt; i++) {
		for (int j = 1; j < xcnt; j++) {
			hline[i][j] += hline[i][j - 1];
		}
	}
	vector<vector<int>>wline(ycnt, vector<int>(xcnt));
	for (auto i : tate) {
//		cout << "xline " << i.d << " " << i.u << " " << i.x << endl;
		wline[i.d][i.x]++;
		wline[i.u][i.x]--;
	}
	for (int i = 1; i < ycnt; i++) {
		for (int j = 0; j < xcnt; j++) {
			wline[i][j] += wline[i - 1][j];
		}
	}
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		int cy = Q.front().first;
		int cx = Q.front().second;
	//	cout << cy << " " << cx << endl;
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= ycnt || nx >= xcnt) {
				cout << "INF" << endl;
				return 0;
				continue;
			}
			if (visit[ny][nx])continue;
			if (ny < cy) {
				if (hline[cy][cx])continue;
			}
			if (ny > cy) {
				if (hline[ny][nx])continue;
			}
			if (nx > cx) {
				if (wline[ny][nx])continue;
			}
			if (nx < cx) {
				if (wline[cy][cx])continue;
			}
			visit[ny][nx] = 1;
			Q.emplace(ny, nx);
		}
	}
	//for (auto i : visit) {
	//	for (auto j : i) {
	//		cout << j << " ";
	//	}
	//	cout << endl;
	//}
	long long int ans = 0;
	for (int i = 0; i < ycnt - 1; i++) {
		for (int j = 0; j < xcnt - 1; j++) {
			ans += (y[i + 1] - y[i])*(x[j + 1] - x[j])*visit[i][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 109596