#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(i64, i64, i64); n],
        w: [(i64, i64, i64); m]
    }
    let mut xs = vec![];
    let mut ys = vec![];
    for &(a, b, c) in &v {
        xs.push(a);
        xs.push(b);
        ys.push(c);
    }
    for &(d, e, f) in &w {
        xs.push(d);
        ys.push(e);
        ys.push(f);
    }

    xs.sort();
    xs.dedup();
    ys.sort();
    ys.dedup();
    let mut g = HashMap::new();
    let mut ar = vec![vec![-1; ys.len() + 1]; xs.len() + 1];
    for i in 0..=xs.len() {
        for j in 0..=ys.len() {
            g.insert((i, j), 0);
            if i != 0 && i != xs.len() && j != 0 && j != ys.len() {
                ar[i][j] = (xs[i] - xs[i - 1]) * (ys[j] - ys[j - 1]);
            }
        }
    }
    for &(a, b, c) in &v {
        let xl = xs.binary_search(&a).unwrap();
        let xr = xs.binary_search(&b).unwrap();
        let y = ys.binary_search(&c).unwrap();
        for i in xl + 1..=xr {
            *g.get_mut(&(i, y)).unwrap() |= 8;
            *g.get_mut(&(i, y + 1)).unwrap() |= 4;
        }
    }
    for &(d, e, f) in &w {
        let x = xs.binary_search(&d).unwrap();
        let yl = ys.binary_search(&e).unwrap();
        let yr = ys.binary_search(&f).unwrap();
        for i in yl + 1..=yr {
            *g.get_mut(&(x, i)).unwrap() |= 2;
            *g.get_mut(&(x + 1, i)).unwrap() |= 1;
        }
    }
    let x0 = match xs.binary_search(&0) {Ok(i) => i, Err(i) => i};
    let y0 = match ys.binary_search(&0) {Ok(i) => i, Err(i) => i};
    if ar[x0][y0] == -1 {
        println!("INF");
        return;
    }
    let mut st = vec![(x0, y0)];
    let mut done = HashSet::new();
    let mut ans = ar[x0][y0];
    done.insert((x0, y0));
    while let Some((i, j)) = st.pop() {
        let con = g.get(&(i, j)).unwrap();
        if con & 1 == 0 && done.insert((i - 1, j)) {
            if ar[i - 1][j] == -1 {
                println!("INF");
                return;
            }
            ans += ar[i - 1][j];
            st.push((i - 1, j));
        }
        if con & 2 == 0 && done.insert((i + 1, j)) {
            if ar[i + 1][j] == -1 {
                println!("INF");
                return;
            }
            ans += ar[i + 1][j];
            st.push((i + 1, j));
        }
        if con & 4 == 0 && done.insert((i, j - 1)) {
            if ar[i][j - 1] == -1 {
                println!("INF");
                return;
            }
            ans += ar[i][j - 1];
            st.push((i, j - 1));
        }
        if con & 8 == 0 && done.insert((i, j + 1)) {
            if ar[i][j + 1] == -1 {
                println!("INF");
                return;
            }
            ans += ar[i][j + 1];
            st.push((i, j + 1));
        }
    }
    println!("{}", ans);
}
