#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
vector<int> dy = {-1, 0, 1, 0};
vector<int> dx = {0, -1, 0, 1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, P>> a(n);
  for (int i = 0; i < (n); ++i)
    cin >> a[i].second.first >> a[i].second.second >> a[i].first;
  vector<pair<ll, P>> d(m);
  for (int i = 0; i < (m); ++i)
    cin >> d[i].first >> d[i].second.first >> d[i].second.second;
  sort(a.begin(), a.end());
  sort(d.begin(), d.end());
  set<ll> xx, yy;
  for (int i = 0; i < (n); ++i) {
    xx.insert(a[i].second.first);
    xx.insert(a[i].second.second);
    yy.insert(a[i].first);
  }
  for (int i = 0; i < (m); ++i) {
    xx.insert(d[i].first);
    yy.insert(d[i].second.first);
    yy.insert(d[i].second.second);
  }
  vector<P> x, y;
  int sx, sy;
  ll INF = 1000000000;
  x.push_back(make_pair(-INF, -INF));
  ll pre = -INF;
  int idx = 0;
  for (ll l : xx) {
    x.push_back(make_pair(pre, l));
    idx++;
    if (pre < 0 && 0 < l) sx = idx;
    pre = l;
    x.push_back(make_pair(l, l));
    idx++;
    if (pre == 0 && l == 0) sx = idx;
  }
  x.push_back(make_pair(pre, INF));
  x.push_back(make_pair(INF, INF));
  y.push_back(make_pair(-INF, -INF));
  pre = -INF;
  idx = 0;
  for (ll l : yy) {
    y.push_back(make_pair(pre, l));
    idx++;
    if (pre < 0 && 0 < l) sy = idx;
    pre = l;
    y.push_back(make_pair(l, l));
    idx++;
    if (pre == 0 && l == 0) sy = idx;
  }
  y.push_back(make_pair(pre, INF));
  y.push_back(make_pair(INF, INF));
  cout << sy << ' ' << sx << endl;
  int h = y.size();
  int w = x.size();
  vector<vector<char>> s(h, vector<char>(w, '.'));
  idx = 0;
  for (int i = 0; i < (n); ++i) {
    while (x[idx].first < a[i].first) idx++;
    for (int j = 0; j < (h); ++j) {
      if (a[i].second.first <= y[j].first &&
          y[j].second <= a[i].second.second) {
        s[j][idx] = '#';
      }
    }
  }
  idx = 0;
  for (int i = 0; i < (m); ++i) {
    while (y[idx].first < d[i].first) idx++;
    for (int j = 0; j < (w); ++j) {
      if (d[i].second.first <= x[j].first &&
          x[j].second <= d[i].second.second) {
        s[idx][j] = '#';
      }
    }
  }
  vector<vector<bool>> vis(h, vector<bool>(w, false));
  queue<P> que;
  que.push(make_pair(sy, sx));
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int y = p.first;
    int x = p.second;
    if (vis[y][x]) continue;
    vis[y][x] = true;
    for (int i = 0; i < (4); ++i) {
      if (y + dy[i] < 0 || y + dy[i] >= h) continue;
      if (x + dx[i] < 0 || x + dx[i] >= w) continue;
      if (s[y + dy[i]][x + dx[i]] == '#') continue;
      if (vis[y + dy[i]][x + dx[i]]) continue;
      que.push(make_pair(y + dy[i], x + dx[i]));
    }
  }
  for (int i = 0; i < (h); ++i) {
    if (vis[i][0] || vis[i][w - 1]) {
      cout << "INF" << endl;
      return 0;
    }
  }
  for (int i = 0; i < (w); ++i) {
    if (vis[0][i] || vis[h - 1][i]) {
      cout << "INF" << endl;
      return 0;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (h); ++i)
    for (int j = 0; j < (w); ++j) {
      if (!vis[i][j]) continue;
      ll area = (y[i].second - y[i].first) * (x[j].second - x[j].first);
      ans += area;
    }
  cout << ans << endl;
}
