#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N), C(N);
  vector<int> D(M), E(M), F(M);
  std::set<int> x_org = {0};
  std::set<int> y_org = {0};
  struct pair3 {
    int a, b, c;
    pair3(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
  };
  std::vector<pair3> Xpair;
  std::vector<pair3> Ypair;
  for (int n = 0; n < N; ++n) {
    cin >> A[n] >> B[n] >> C[n];
    Xpair.emplace_back(A[n], B[n], C[n]);
    x_org.insert(A[n]);
    x_org.insert(B[n]);
    y_org.insert(C[n]);
  }
  for (int m = 0; m < M; ++m) {
    cin >> D[m] >> E[m] >> F[m];
    Ypair.emplace_back(D[m], E[m], F[m]);
    x_org.insert(D[m]);
    y_org.insert(E[m]);
    y_org.insert(F[m]);
  }
  vector<int> X, Y;
  std::map<int, int> mx;
  std::map<int, int> my;
  for (auto itr = x_org.begin(); itr != x_org.end(); ++itr) {
    mx[*itr] = X.size();
    X.push_back(*itr);
  }
  for (auto itr = y_org.begin(); itr != y_org.end(); ++itr) {
    my[*itr] = Y.size();
    Y.push_back(*itr);
  }
  int x = 2 * X.size() + 1;
  int y = 2 * Y.size() + 1;
  vector<vector<int>> XY(x, vector<int>(y));
  for (int n = 0; n < (int)Xpair.size(); ++n) {
    for (int m = mx[Xpair[n].a] * 2 + 1; m <= mx[Xpair[n].b] * 2 + 1; ++m) {
      XY[m][my[Xpair[n].c] * 2 + 1] = -1;
    }
  }
  for (int n = 0; n < (int)Ypair.size(); ++n) {
    for (int m = my[Ypair[n].b] * 2 + 1; m <= my[Ypair[n].c] * 2 + 1; ++m) {
      XY[mx[Ypair[n].a] * 2 + 1][m] = -1;
    }
  }
  queue<pair<int, int>> q;
  XY[mx[0] * 2 + 1][my[0] * 2 + 1] = 1;
  q.emplace(mx[0] * 2 + 1, my[0] * 2 + 1);
  while (!q.empty()) {
    int x0 = q.front().first;
    int y0 = q.front().second;
    q.pop();
    {
      int x1 = x0 + 1;
      int y1 = y0;
      if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
        XY[x1][y1] = 1;
        q.emplace(x1, y1);
      }
    }
    {
      int x1 = x0 - 1;
      int y1 = y0;
      if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
        XY[x1][y1] = 1;
        q.emplace(x1, y1);
      }
    }
    {
      int x1 = x0;
      int y1 = y0 + 1;
      if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
        XY[x1][y1] = 1;
        q.emplace(x1, y1);
      }
    }
    {
      int x1 = x0;
      int y1 = y0 - 1;
      if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
        XY[x1][y1] = 1;
        q.emplace(x1, y1);
      }
    }
  }
  cout << "INF" << endl;
  return 0;
}
