There is a grass field that stretches infinitely.

In this field, there is a negligibly small cow. Let (x, y) denote the point that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).

There are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).

What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print `INF` instead.

Constraints

* All values in input are integers between -10^9 and 10^9 (inclusive).
* 1 \leq N, M \leq 1000
* A_i < B_i\ (1 \leq i \leq N)
* E_j < F_j\ (1 \leq j \leq M)
* The point (0, 0) does not lie on any of the given segments.

Input

Input is given from Standard Input in the following format:


N M
A_1 B_1 C_1
:
A_N B_N C_N
D_1 E_1 F_1
:
D_M E_M F_M


Output

If the area of the region the cow can reach is infinite, print `INF`; otherwise, print an integer representing the area in \mathrm{cm^2}.

(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)

Examples

Input

5 6
1 2 0
0 1 1
0 2 2
-3 4 -1
-2 6 3
1 0 1
0 1 2
2 0 2
-1 -4 5
3 -2 4
1 2 4


Output

13


Input

6 1
-3 -1 -2
-3 -1 1
-2 -1 2
1 4 -2
1 4 -1
1 4 1
3 1 4


Output

INF
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Set;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FSingleDot solver = new FSingleDot();
        solver.solve(1, in, out);
        out.close();
    }

    static class FSingleDot {
        public static final long INF = 1_000_000_001L;
        private int n;
        private int m;
        private int[] a;
        private int[] b;
        private int[] c;
        private int[] d;
        private int[] e;
        private int[] f;
        private boolean[][] wallAtX;
        private boolean[][] wallAtY;
        private int nbX;
        private int nbY;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
        /*if (testNumber==1) {
            random();
            return;
        }*/
            n = in.nextInt();
            m = in.nextInt();
            a = new int[n];
            b = new int[n];
            c = new int[n];
            d = new int[m];
            e = new int[m];
            f = new int[m];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
            }
            for (int i = 0; i < m; i++) {
                d[i] = in.nextInt();
                e[i] = in.nextInt();
                f[i] = in.nextInt();
            }

            long res = solveMe();
            out.println(res == -1 ? "INF" : res);
        }

        private long solveMe() {
            //get wallX
            //get wallY
            long ans = 0;

            HashMap<Long, Integer> defaultMap = new HashMap<>();
            defaultMap.put(0L, null);
            defaultMap.put(-INF, null);
            defaultMap.put(INF, null);
            HashMap<Long, Integer> mapX = new HashMap<>(defaultMap);
            HashMap<Long, Integer> mapY = new HashMap<>(defaultMap);

            mapX.put(0L, null);
            for (int i = 0; i < n; i++) {
                mapX.put((long) a[i], null);
                mapX.put((long) b[i], null);
                mapY.put((long) c[i], null);
            }
            mapY.put(0L, null);
            for (int i = 0; i < m; i++) {
                mapX.put((long) d[i], null);
                mapY.put((long) e[i], null);
                mapY.put((long) f[i], null);
            }

            nbX = mapX.size();
            Long[] valX = mapX.keySet().toArray(new Long[0]);
            Arrays.sort(valX);
            for (int i = 0; i < nbX; i++) {
                mapX.put(valX[i], i);
            }

            nbY = mapY.size();
            Long[] valY = mapY.keySet().toArray(new Long[0]);
            Arrays.sort(valY);
            for (int i = 0; i < nbY; i++) {
                mapY.put(valY[i], i);
            }

            FSingleDot.MyVertex[][] vertices = new FSingleDot.MyVertex[nbX - 1][nbY - 1];
            for (int i = 0; i < nbX - 1; i++)
                for (int j = 0; j < nbY - 1; j++) {
                    Long val = (i == 0 || j == 0 || i == nbX - 2 || j == nbY - 2) ? null : (valX[i + 1] - valX[i]) * (valY[j + 1] - valY[j]);
                    vertices[i][j] = new FSingleDot.MyVertex(i, j, val);
                }

            wallAtX = new boolean[nbX][nbY - 1];
            wallAtY = new boolean[nbX - 1][nbY];
            for (int i = 0; i < n; i++) {
                int start = mapX.get((long) a[i]);
                int end = mapX.get((long) b[i]);
                int y = mapY.get((long) c[i]);
                for (int j = start; j < end; j++) {
                    wallAtY[j][y] = true;
                }
            }

            for (int i = 0; i < m; i++) {
                int start = mapY.get((long) e[i]);
                int end = mapY.get((long) f[i]);
                int x = mapX.get((long) d[i]);
                for (int j = start; j < end; j++) {
                    wallAtX[x][j] = true;
                }
            }

            boolean[][] visited = new boolean[nbX - 1][nbY - 1];
            ArrayDeque<FSingleDot.MyVertex> list = new ArrayDeque<>();
            list.add(vertices[mapX.get(0L)][mapY.get(0L)]);
            //d(s("nextX", mapX.get((long)0), "nextY", mapY.get((long)0)));
            visited[0][0] = true;
            int[][] moves = new int[][]{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
            //d("wallX", stringMe(wallAtX));
            //d("wallY", stringMe(wallAtY));

            while (!list.isEmpty()) {
                FSingleDot.MyVertex cur = list.pop();
                for (int i = 0; i < moves.length; i++) {
                    int nextX = cur.xPos + moves[i][0];
                    int nextY = cur.yPos + moves[i][1];
                    //d(s("nextX", valX[nextX], "nextY", valY[nextY]));
                    if (isInside(nextX, nextY) && !visited[nextX][nextY] && !hasWall(cur, moves[i])) {
                        //d("is ok");
                        FSingleDot.MyVertex nextVertex = vertices[nextX][nextY];
                        visited[nextX][nextY] = true;
                        if (nextVertex.val == null)
                            return -1;
                        ans += nextVertex.val;
                        list.add(nextVertex);
                    }
                }
            }
            return ans;
        }

        private boolean hasWall(FSingleDot.MyVertex cur, int[] move) {
            if (move[0] != 0) {
                return (move[0] == 1 && wallAtX[cur.xPos + 1][cur.yPos]) || (move[0] == -1 && wallAtX[cur.xPos][cur.yPos]);
            } else {
                return (move[1] == 1 && wallAtY[cur.xPos][cur.yPos + 1] || (move[1] == -1 && wallAtY[cur.xPos][cur.yPos]));
            }
        }

        private boolean isInside(int nextX, int nextY) {
            return nextX >= 0 && nextX < nbX - 1 && nextY >= 0 && nextY < nbY - 1;
        }

        public static class MyVertex {
            int xPos;
            int yPos;
            Long val;

            public MyVertex(int xPos, int yPos, Long val) {
                this.xPos = xPos;
                this.yPos = yPos;
                this.val = val;
            }

        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

