There is a grass field that stretches infinitely.

In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).

There are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).

What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print `INF` instead.

Constraints

* All values in input are integers between -10^9 and 10^9 (inclusive).
* 1 \leq N, M \leq 1000
* A_i < B_i\ (1 \leq i \leq N)
* E_j < F_j\ (1 \leq j \leq M)
* The point (0, 0) does not lie on any of the given segments.

Input

Input is given from Standard Input in the following format:


N M
A_1 B_1 C_1
:
A_N B_N C_N
D_1 E_1 F_1
:
D_M E_M F_M


Output

If the area of the region the cow can reach is infinite, print `INF`; otherwise, print an integer representing the area in \mathrm{cm^2}.

(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)

Examples

Input

5 6
1 2 0
0 1 1
0 2 2
-3 4 -1
-2 6 3
1 0 1
0 1 2
2 0 2
-1 -4 5
3 -2 4
1 2 4


Output

13


Input

6 1
-3 -1 -2
-3 -1 1
-2 -1 2
1 4 -2
1 4 -1
1 4 1
3 1 4


Output

INF
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

const int inf = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> vx = {0, -inf, inf}, vy = {0, -inf, inf};
	vector<pair<pair<int, int>, int>> hor(n);
	for (auto& x : hor) {
		cin >> x.first.first >> x.first.second >> x.second;
		vx.push_back(x.first.first);
		vx.push_back(x.first.second);
		vy.push_back(x.second);
	}
	vector<pair<int, pair<int, int>>> ver(m);
	for (auto& x : ver) {
		cin >> x.first >> x.second.first >> x.second.second;
		vx.push_back(x.first);
		vy.push_back(x.second.first);
		vy.push_back(x.second.second);
	}
	auto compr = [&] (vector<int>& v) {
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
	};
	auto f = [&] (vector<int>& v, int& x) {
		x = lower_bound(v.begin(), v.end(), x) - v.begin();
	};
	compr(vx);
	compr(vy);
	for (auto& x : hor) {
		f(vx, x.first.first);
		f(vx, x.first.second);
		f(vy, x.second);
	}
	for (auto& x : ver) {
		f(vx, x.first);
		f(vy, x.second.first);
		f(vy, x.second.second);
	}
	vector<vector<bool>> kek(vx.size(), vector<bool>(vy.size(), false));
	vector<vector<bool>> lol(vx.size(), vector<bool>(vy.size(), false));
	for (auto x : hor) {
		for (int i = x.first.first; i < x.first.second; i++) kek[i][x.second] = true;
	}
	for (auto x : ver) {
		for (int i = x.second.first; i < x.second.second; i++) lol[x.first][i] = true;
	}
	vector<vector<bool>> used(vx.size(), vector<bool>(vy.size(), false));
	pair<int, int> st = {0, 0};
	f(vx, st.first);
	f(vy, st.second);
	auto ok = [&] (pair<int, int> p) {
		return p.first >= 0 && p.first + 1 < vx.size() && p.second >= 0 && p.second + 1 < vy.size() && !used[p.first][p.second];
	};
	vector<pair<int, int>> q = {st};
	used[st.first][st.second] = true;
	auto add = [&] (pair<int, int> p) {
		used[p.first][p.second] = true;
		q.push_back(p);
	};
	while (!q.empty()) {
		auto v = q.back();
		q.pop_back();
		if (ok({v.first - 1, v.second}) && !lol[v.first][v.second]) add({v.first - 1, v.second});
		if (ok({v.first + 1, v.second}) && !lol[v.first + 1][v.second]) add({v.first + 1, v.second});
		if (ok({v.first, v.second - 1}) && !kek[v.first][v.second]) add({v.first, v.second - 1});
		if (ok({v.first, v.second + 1}) && !kek[v.first][v.second + 1]) add({v.first, v.second + 1});
	}
	for (int i = 0; i + 1 < vx.size(); i++) {
		for (int j = 0; j + 1 < vy.size(); j++) {
			if (used[i][j] && (i == 0 || j == 0 || i + 2 == vx.size() || j + 2 == vy.size())) {
				cout << "INF\n";
				return 0;
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i + 1 < vx.size(); i++) {
		for (int j = 0; j + 1 < vy.size(); j++) {
			if (used[i][j]) ans += (ll) (vx[i + 1] - vx[i]) * (vy[j + 1] - vy[j]);
		}
	}
	cout << ans;
	return 0;
}

