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()
}

const INF: i64 = 10001;

fn main() {
    let nm = reads();
    let mut xs = vec![vec![INF; nm[0]]; nm[0]];

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

        let l = lrd[0] - 1;
        let r = lrd[1] - 1;
        let d = lrd[2] as i64;

        xs[l][r] = d;
        xs[r][l] = -d;
    }

    let mut bs = vec![true; nm[0]];
    let mut vs = vec![0i64; nm[0]];
    let mut res = true;

    for i in 0..nm[0] {
        if bs[i] {
            vs[i] = 0;
            res = visit(i, &xs, &mut bs, &mut vs);
            if !res {
                break;
            }
        }
    }

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

fn visit(i: usize, xs: &Vec<Vec<i64>>, bs: &mut Vec<bool>, vs: &mut Vec<i64>) -> bool {
    let mut res = true;
    bs[i] = false;

    for j in 0..bs.len() {
        if INF > xs[i][j] {
            if bs[j] {
                vs[j] = vs[i] + xs[i][j];
                res = visit(j, xs, bs, vs);
                if !res {
                    break;
                }
            }
            else {
                res = vs[j] == vs[i] + xs[i][j];
                if !res {
                    break;
                }
            }
        }
    }

    res
}