#include <bits/stdc++.h>
long INF1 = 2000000000;
long INF2 = INF1 * INF1;
class CoordData;
std::map<long, CoordData *> xVals, yVals;
std::vector<long> xReal, yReal;
class CoordData {
 public:
  CoordData(long val, int index, int listNum) {
    _val = val;
    _posLists[listNum].push_back(index);
  }
  void SetMappedValue(int mappedValue) { _mappedVal = mappedValue; }
  int MappedValue() { return _mappedVal; }
  long RealValue() { return _val; }
  void AddIndex(int index, int listNum) { _posLists[listNum].push_back(index); }
  static void AddXData(long val, int index, int listNum) {
    _AddCoordData(val, index, listNum, xVals);
  }
  static void AddYData(long val, int index, int listNum) {
    _AddCoordData(val, index, listNum, yVals);
  }

 private:
  long _val;
  int _mappedVal;
  std::vector<int> _posLists[3];
  static void _AddCoordData(long val, int index, int listNum,
                            std::map<long, CoordData *> &vals) {
    if (vals.count(val) == 0) {
      vals.insert(std::pair<long, CoordData *>(
          val, new CoordData(val, index, listNum)));
    } else {
      vals[val]->AddIndex(index, listNum);
    }
  }
};
class Cell;
std::vector<std::vector<Cell *> > grid;
class Pos {
 public:
  Pos(int x, int y) {
    X = x;
    Y = y;
  }
  int X, Y;
};
class Cell {
 public:
  Cell(int x, int y) {
    Vis = false;
    _x = x;
    _y = y;
    _neighbors.push_back(new Pos(x, y + 1));
    _neighbors.push_back(new Pos(x + 1, y));
    if (x > 0) {
      _neighbors.push_back(new Pos(x - 1, y));
    }
    if (y > 0) {
      _neighbors.push_back(new Pos(x, y - 1));
    }
  }
  void RemoveNeighbor(int x, int y) {
    for (int i = 0; i < _neighbors.size(); i++) {
      if (_neighbors[i]->X == x && _neighbors[i]->Y == y) {
        _neighbors.erase(_neighbors.begin() + i);
        return;
      }
    }
    throw 2;
  }
  long Area() {
    if (_x == 0 || _y == 0) return INF2;
    if (_x == xReal.size() - 1 || _y == yReal.size() - 1) return INF2;
    long x2 = xVals[xReal[_x + 1]]->RealValue();
    long x1 = xVals[xReal[_x]]->RealValue();
    long y2 = yVals[yReal[_y + 1]]->RealValue();
    long y1 = yVals[yReal[_y]]->RealValue();
    long dx = x2 - x1;
    long dy = y2 - y1;
    return dx * dy;
  }
  std::vector<Pos *> Neighbors() { return _neighbors; }
  bool Vis;

 private:
  int _x, _y;
  std::vector<Pos *> _neighbors;
};
std::vector<long> a, b, c, d, e, f;
int main() {
  int N, M;
  std::cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int A, B, C;
    std::cin >> A >> B >> C;
    CoordData::AddXData(A, i, 0);
    CoordData::AddXData(B, i, 1);
    CoordData::AddYData(C, i, 2);
    a.push_back(A);
    b.push_back(B);
    c.push_back(C);
  }
  for (int i = 0; i < M; i++) {
    int D, E, F;
    std::cin >> D >> E >> F;
    CoordData::AddXData(D, i, 2);
    CoordData::AddYData(E, i, 0);
    CoordData::AddYData(F, i, 1);
    d.push_back(D);
    e.push_back(E);
    f.push_back(F);
  }
  int mappedValue, mappedZeroX = -1, mappedZeroY = -1;
  std::map<long, CoordData *>::iterator it;
  xReal.push_back(-INF1);
  mappedValue = 0;
  for (it = xVals.begin(); it != xVals.end(); it++) {
    long realValue = it->first;
    mappedValue++;
    xReal.push_back(realValue);
    it->second->SetMappedValue(mappedValue);
    if (realValue > 0 && mappedZeroX == -1) {
      mappedZeroX = mappedValue - 1;
    }
  }
  xReal.push_back(INF1);
  if (mappedZeroX <= 0) {
    std::cout << "INF\n";
    return 0;
  }
  yReal.push_back(-INF1);
  mappedValue = 0;
  for (it = yVals.begin(); it != yVals.end(); it++) {
    long realValue = it->first;
    mappedValue++;
    yReal.push_back(realValue);
    it->second->SetMappedValue(mappedValue);
    if (realValue > 0 && mappedZeroY == -1) {
      mappedZeroY = mappedValue - 1;
    }
  }
  yReal.push_back(INF1);
  if (mappedZeroY <= 0) {
    std::cout << "INF\n";
    return 0;
  }
  Pos *Zero = new Pos(mappedZeroX, mappedZeroY);
  int Nx = xReal.size();
  int Ny = yReal.size();
  for (int x = 0; x < Nx; x++) {
    grid.push_back(std::vector<Cell *>());
    for (int y = 0; y < Ny; y++) {
      grid[x].push_back(new Cell(x, y));
    }
  }
  for (int i = 0; i < N; i++) {
    int A = xVals[a[i]]->MappedValue();
    int B = xVals[b[i]]->MappedValue();
    int C = yVals[c[i]]->MappedValue();
    for (int x = A; x < B; x++) {
      grid[x][C - 1]->RemoveNeighbor(x, C);
      grid[x][C]->RemoveNeighbor(x, C - 1);
    }
  }
  for (int j = 0; j < M; j++) {
    int D = xVals[d[j]]->MappedValue();
    int E = yVals[e[j]]->MappedValue();
    int F = yVals[f[j]]->MappedValue();
    for (int y = E; y < F; y++) {
      grid[D][y]->RemoveNeighbor(D - 1, y);
      grid[D - 1][y]->RemoveNeighbor(D, y);
    }
  }
  long res = 0;
  std::stack<Pos *> s;
  grid[Zero->X][Zero->Y]->Vis = true;
  s.push(Zero);
  while (!s.empty()) {
    Pos *curr = s.top();
    s.pop();
    Cell *cell = grid[curr->X][curr->Y];
    long dArea = cell->Area();
    if (dArea == INF2) {
      std::cout << "INF\n";
      return 0;
    }
    res += dArea;
    std::vector<Pos *> neighbors = cell->Neighbors();
    for (int i = 0; i < neighbors.size(); i++) {
      Pos *next = neighbors[i];
      Cell *nextCell = grid[next->X][next->Y];
      if (!nextCell->Vis) {
        s.push(neighbors[i]);
        nextCell->Vis = true;
      }
    }
  }
  std::cout << res << "\n";
}
