#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long int MAX = 1e9 + 7;
void array_show(int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%d%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void array_show(long long int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%lld%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void array_show(vector<int> &vec_s, int vec_n = -1, char middle = ' ') {
  if (vec_n == -1) vec_n = vec_s.size();
  for (int i = 0; i < vec_n; i++)
    printf("%d%c", vec_s[i], (i != vec_n - 1 ? middle : '\n'));
}
void array_show(vector<long long int> &vec_s, int vec_n = -1,
                char middle = ' ') {
  if (vec_n == -1) vec_n = vec_s.size();
  for (int i = 0; i < vec_n; i++)
    printf("%lld%c", vec_s[i], (i != vec_n - 1 ? middle : '\n'));
}
int t[2200][3];
map<long long int, int> m1[2];
bool used[2200][2200];
int sq[2200][2200];
const int N = 2100;
long long int check(int a, int b) {
  if (a < 0 || a > N || b < 0 || b > N) return -1;
  if (used[a][b]) return 0;
  used[a][b] = true;
  long long int s = sq[a][b];
  long long int p;
  for (int i = -1; i <= 1; i++) {
    for (int j = -1; j <= 1; j++) {
      if ((i + j + 2) % 2 == 0) continue;
      p = check(a + i, b + j);
      if (p == -1) return -1;
      s += p;
    }
  }
  return s;
}
int main() {
  int n, m;
  int i, j, k;
  long long int a, b, c, d;
  cin >> n >> m;
  m1[0][0] = 1, m1[1][0] = 1;
  for (i = 0; i < n + m; i++) {
    for (j = 0; j < 3; j++) {
      cin >> t[i][j];
      if (i < n) {
        if (j < 2)
          a = 0;
        else
          a = 1;
      } else {
        if (j < 1)
          a = 0;
        else
          a = 1;
      }
      m1[a][t[i][j]] = 1;
    }
  }
  vector<long long int> v[2];
  for (i = 0; i < 2; i++) {
    j = 0;
    for (auto &node : m1[i]) {
      node.second = j++;
      v[i].push_back(node.first);
    }
  }
  for (i = 0; i < n + m; i++) {
    if (i < n) {
      a = m1[0][t[i][0]] * 2, b = m1[1][t[i][2]] * 2;
      c = m1[0][t[i][1]] * 2, d = m1[1][t[i][2]] * 2;
    } else {
      a = m1[0][t[i][0]] * 2, b = m1[1][t[i][1]] * 2;
      c = m1[0][t[i][0]] * 2, d = m1[1][t[i][2]] * 2;
    }
    while (a <= c && b <= d) {
      used[a][b] = true;
      if (i < n)
        a++;
      else
        b++;
    }
  }
  for (i = 0; i + 1 < v[0].size(); i++) {
    for (j = 0; j + 1 < v[1].size(); j++) {
      sq[2 * i + 1][2 * j + 1] =
          (v[0][i + 1] - v[0][i]) * (v[1][j + 1] - v[1][j]);
    }
  }
  a = m1[0][0], b = m1[1][0];
  a = check(a * 2, b * 2);
  if (a == -1)
    cout << "INF" << endl;
  else
    cout << a << endl;
}
