using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    class P
    {
        public int index;
        public List<int> ad;
        public Dictionary<int, int> weights;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
            weights = new Dictionary<int, int>();
        }
    }
    private static bool Imp = false;
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ps = new P[nm[0]];
        for (var i = 0; i < nm[0]; i++)
            ps[i] = new P(i);
        for(var i = 0; i < nm[1]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            for(var j = -1; j < 2; j+=2)
            {
                ps[input[(j + 1) / 2] - 1].ad.Add(input[(2 - j) / 3] - 1);
                ps[input[(j + 1) / 2] - 1].weights[input[(2 - j) / 3] - 1] = -j * input[2];
            }
        }
        var set = new HashSet<int>();
        for (var i = 0; i < nm[0]; i++)
            if (!set.Contains(i))
                dfs(ps, i, set, new int[nm[0]]);
        WriteLine(Imp ? "No" : "Yes");
    }
    private static void dfs(P[] ps,int index,HashSet<int> set,int[] val)
    {
        set.Add(index);
        foreach (var ad in ps[index].ad)
        {
            if (!set.Contains(ad)&&!Imp)
            {
                val[ad] = val[index] + ps[index].weights[ad];
                dfs(ps, ad, set, val);
            }
            if (val[ad] != val[index] + ps[index].weights[ad])
                Imp = true;
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}
