using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N, M;
    long[] A, B, C;
    long[] D, E, F;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        A = new long[N];
        B = new long[N];
        C = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.NextInt();
            B[i] = sc.NextInt();
            C[i] = sc.NextInt();
        }

        D = new long[M];
        E = new long[M];
        F = new long[M];
        for (int i = 0; i < M; i++)
        {
            D[i] = sc.NextInt();
            E[i] = sc.NextInt();
            F[i] = sc.NextInt();
        }

        // 座圧
        var xHs = new HashSet<long>();
        var yHs = new HashSet<long>();
        xHs.Add(-1500000001);
        xHs.Add(1500000001);
        yHs.Add(-1500000001);
        yHs.Add(1500000001);
        for (int i = 0; i < N; i++)
        {
            xHs.Add(A[i]);
            xHs.Add(B[i]);
            yHs.Add(C[i]);
        }
        for (int i = 0; i < M; i++)
        {
            xHs.Add(D[i]);
            yHs.Add(E[i]);
            yHs.Add(F[i]);
        }

        var xAr = xHs.ToArray();
        Array.Sort(xAr);
        var yAr = yHs.ToArray();
        Array.Sort(yAr);
        var xMap = new Dictionary<long, int>();
        var yMap = new Dictionary<long, int>();
        for (int i = 0; i < xAr.Length; i++)
        {
            xMap[xAr[i]] = i;
        }
        for (int i = 0; i < yAr.Length; i++)
        {
            yMap[yAr[i]] = i;
        }

        // グリッドの面積
        var grid = new long[xAr.Length * 2 - 1, yAr.Length * 2 - 1];
        // i, jが通れ無いか?
        var f = new bool[xAr.Length * 2 - 1, yAr.Length * 2 - 1];

        for (int i = 0; i < xAr.Length - 1; i++)
        {
            for (int j = 0; j < yAr.Length - 1; j++)
            {
                grid[i * 2 + 1, j * 2 + 1] = (xAr[i + 1] - xAr[i]) * (yAr[j + 1] - yAr[j]);
            }
        }

        for (int i = 0; i < N; i++)
        {
            int l = xMap[A[i]];
            int r = xMap[B[i]];

            int y = yMap[C[i]];
            for (int j = 2 * l; j <= 2 * r; j++)
            {
                f[j, y * 2] = true;
            }
        }
        for (int i = 0; i < N; i++)
        {
            int l = xMap[A[i]];
            int r = xMap[B[i]];

            int y = yMap[C[i]];
            for (int j = 2 * l; j <= 2 * r; j++)
            {
                f[j, y * 2] = true;
            }
        }
        for (int i = 0; i < M; i++)
        {
            int l = yMap[E[i]];
            int r = yMap[F[i]];

            int x = xMap[D[i]];
            for (int j = 2 * l; j <= 2 * r; j++)
            {
                f[x * 2, j] = true;
            }
        }
        int sx = -1;
        int sy = -1;
        for (int i = 0; i < xAr.Length - 1; i++)
        {
            for (int j = 0; j < yAr.Length - 1; j++)
            {
                if (xAr[i] <= 0 && 0 <= xAr[i + 1] && yAr[j] <= 0 && 0 <= yAr[j + 1])
                {
                    sx = i * 2 + 1;
                    sy = j * 2 + 1;
                    break;
                }
            }
            if (sx != -1) break;
        }
        // Console.WriteLine($"{sx} {sy}");
        var dx = new int[] { 1, 0, -1, 0 };
        var dy = new int[] { 0, 1, 0, -1 };

        var xq = new Queue<int>();
        var yq = new Queue<int>();
        var flag = new bool[xAr.Length * 2 - 1, yAr.Length * 2 - 1];
        xq.Enqueue(sx);
        yq.Enqueue(sy);
        flag[sx, sy] = true;

        while (xq.Count > 0)
        {
            var xx = xq.Dequeue();
            var yy = yq.Dequeue();
            for (int i = 0; i < 4; i++)
            {
                int nx = xx + dx[i];
                int ny = yy + dy[i];
                if (nx < 0 || nx >= xAr.Length * 2 - 1) continue;
                if (ny < 0 || ny >= yAr.Length * 2 - 1) continue;
                if (f[nx, ny]) continue;
                if (flag[nx, ny]) continue;
                flag[nx, ny] = true;
                xq.Enqueue(nx);
                yq.Enqueue(ny);
            }
        }

        long ans = 0;
        for (int i = 0; i < xAr.Length * 2 - 1; i++)
        {
            for (int j = 0; j < yAr.Length * 2 - 1; j++)
            {
                if ((i == 0 || j == 0 || i == xAr.Length * 2 - 2 || j == yAr.Length * 2 - 2) && flag[i, j])
                {
                    // Console.WriteLine($"{i} {j}");
                    Console.WriteLine("INF");
                    return;
                }
                if (flag[i, j])
                {
                    // Console.WriteLine($"{i} {j} {grid[i, j]}");
                    ans += grid[i, j];
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 251440