#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};

fn dfs(g: HashMap<usize, HashMap<usize, i32>>) -> bool {
    use std::collections::VecDeque;

    let mut visited: HashMap<usize, i32> = HashMap::new();

    loop {
        let mut start = None;
        for k in g.keys() {
            if !visited.contains_key(k) {
                start = Some(*k);
                break;
            }
        }

        if let Some(start) = start {
            visited.insert(start, 0);
            let mut queue = VecDeque::new();
            queue.push_back(start);

            while !queue.is_empty() {
                let p = queue.pop_front().unwrap();
                let pos = *visited.get(&p).unwrap();
                for (n, c) in g.get(&p).unwrap() {
                    match visited.entry(*n) {
                        Vacant(entry) => {
                            entry.insert(*c+pos);
                            queue.push_back(*n);
                        },
                        Occupied(entry) => {
                            let d = *entry.into_mut();
                            if d != (*c + pos) {
                                return false;
                            }
                        }
                    }
                }
            }
        } else {
            return true;
        }
    }

    unreachable!()
}

fn solve(lrd: Vec<(usize, usize, i32)>) -> bool {

    let mut g: HashMap<usize, HashMap<usize, i32>> = HashMap::new();

    for (l,r,d) in lrd {
        {
            let mut sub = g.entry(l).or_insert(HashMap::new());
            match sub.entry(r) {
                Vacant(entry) => {
                    entry.insert(d);
                },
                Occupied(entry) => {
                    if *entry.into_mut() != d {
                        return false;
                    }
                }
            }
        }

        {
            let mut sub = g.entry(r).or_insert(HashMap::new());
            match sub.entry(l) {
                Vacant(entry) => {
                    entry.insert(-d);
                },
                Occupied(entry) => {
                    if *entry.into_mut() != -d {
                        return false;
                    }
                }
            }
        }
    }

    dfs(g)
}

fn main() {
    let (_, m) = parse_line!(usize, usize);

    let lrd = (0..m).map(|_| parse_line!(usize, usize, i32)).collect();

    println!("{}", if solve(lrd) { "Yes" } else { "No" });
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![(1,2,1),
                          (2,3,1),
                          (1,3,2)]), true);

    assert_eq!(solve(vec![(1,2,1),
                          (2,3,1),
                          (1,3,5)]), false);

    assert_eq!(solve(vec![(2,1,1),
                          (2,3,5),
                          (3,4,2)]), true);

    assert_eq!(solve(vec![(8,7,100),
                          (7,9,100),
                          (9,8,100)]), false);

    assert_eq!(solve(vec![]), true);
}


Measured memory_bytes: 102652