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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0x1fffffffffffffffL;
    static final int iinf = 0x3fffffff;
    static final int[] da = {-1, 0, 1, 0, -1, 1, 1, -1, -1};

    int h, w;
    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        Map<Integer, Integer> xm = new TreeMap<>();
        Map<Integer, Integer> ym = new TreeMap<>();
        xm.put(-1500000000, 0);
        xm.put(1500000000, 0);
        xm.put(0, 0);
        ym.put(-1500000000, 0);
        ym.put(1500000000, 0);
        ym.put(0, 0);
        List<Line> verticalLines = new ArrayList<>();
        List<Line> horizontalLines = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            xm.put(a, 0);
            ym.put(c, 0);
            xm.put(b, 0);
            verticalLines.add(new Line(a, c, b, c));
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            xm.put(a, 0);
            ym.put(b, 0);
            ym.put(c, 0);
            horizontalLines.add(new Line(a, b, a, c));
        }
        {
            int i = 0;
            for (Map.Entry<Integer, Integer> entry : xm.entrySet()) {
                entry.setValue(i);
                i += 2;
            }
        }
        {
            int i = 0;
            for (Map.Entry<Integer, Integer> entry : ym.entrySet()) {
                entry.setValue(i);
                i += 2;
            }
        }
        w = xm.size() * 2 - 1;
        h = ym.size() * 2 - 1;
        long[] width = size(xm);
        long[] height = size(ym);
        int[][] c = new int[h + 1][w + 1];
        int[][] r = new int[h + 1][w + 1];
        for (Line line : verticalLines) {
            line.x1 = xm.get(line.x1);
            line.x2 = xm.get(line.x2);
            line.y1 = ym.get(line.y1);
            line.y2 = ym.get(line.y2);
            c[line.y1][line.x1]++;
            c[line.y2][line.x2 + 1]--;
        }
        for (Line line : horizontalLines) {
            line.x1 = xm.get(line.x1);
            line.x2 = xm.get(line.x2);
            line.y1 = ym.get(line.y1);
            line.y2 = ym.get(line.y2);
            r[line.y1][line.x1]++;
            r[line.y2 + 1][line.x2]--;
        }
        boolean[][] wall = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                c[i][j + 1] += c[i][j];
                r[i + 1][j] += r[i][j];
                wall[i][j] = c[i][j] >= 1 || r[i][j] >= 1;
            }
        }
        boolean[][] visited = new boolean[h][w];
        visited[ym.get(0)][xm.get(0)] = true;
        Deque<Point> deque = new ArrayDeque<>();
        deque.add(new Point(xm.get(0), ym.get(0)));
        long ans = 0;
        while (!deque.isEmpty()) {
            Point point = deque.pollFirst();
            if (point.x == 0 || point.y == 0) {
                out.println("INF");
                return;
            }
            for (int i = 0; i < 4; i++) {
                Point next = new Point(point.x + da[i], point.y + da[i + 1]);
                if (next.x < 0 || w <= next.x || next.y < 0 || h <= next.y) {
                    continue;
                }
                if (!wall[next.y][next.x] && !visited[next.y][next.x]) {
                    ans += width[next.x] * height[next.y];
                    visited[next.y][next.x] = true;
                    deque.addLast(next);
                }
            }
        }
        out.println(ans);
    }

    long[] size(Map<Integer, Integer> map) {
        int n = map.size() * 2 - 1;
        int i = -1;
        long[] a = new long[n];
        boolean isFirst = true;
        int last = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (!isFirst) {
                a[i] = entry.getKey() - last;
            }
            i += 2;
            isFirst = false;
            last = entry.getKey();
        }
        return a;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class Point {
    int x;
    int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class Line {
    int x1, y1;
    int x2, y2;

    public Line(int x1, int y1, int x2, int y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}
