fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let nm = reads();
    let inf = 10001;
    let mut xs = vec![vec![inf; nm[0]]; nm[0]];
    let mut bs = vec![vec![false; nm[0]]; nm[0]];
    //let mut vs = vec![];
    let mut res = true;

    for _ in 0..nm[1] {
        let lrd: Vec<usize> = reads();
        let l = lrd[0] - 1;
        let r = lrd[1] - 1;
        let d = lrd[2];

        xs[l][r] = d;
        bs[l][r] = true;

        if res {
            for k in 0..nm[0] {
                if xs[l][r] > xs[l][k] + xs[k][r] {
                    res = false;
                    break;
                }
            }
        }
        
    }
    //let ys = xs.clone();

    //let mut res = true;
/*
    'outer:
    for i in 0..nm[0] {
        for j in 0..nm[0] {
            for k in 0..nm[0] {
                if xs[i][j] > xs[i][k] + xs[k][j] {
                    if bs[i][j] {
                        res = false;
                        break 'outer;
                    }
                    
                    //xs[i][j] = xs[i][k] + xs[k][j];
                }
            }
        }
    }
*/
    if res {
        let mut cs = vec![0; nm[0]];
        
        for i in 0..nm[0] {
            if cs[i] == 0 {
                res = visit(i, &xs, &mut cs);
                if !res {
                    break;
                }
            }
        }
    }

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

fn visit(i: usize, ys: &Vec<Vec<usize>>, cs: &mut Vec<u64>) -> bool {
    let inf = 10001;
    let mut res = true;

    if cs[i] == 1 {
        res = false;
    }
    else if cs[i] == 0 {
        cs[i] = 1;

        for j in 0..cs.len() {
            if inf > ys[i][j] && !visit(j, ys, cs) {
                res = false;
                break;
            }
        }

        cs[i] = 2;
    }

    res
}