using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Security.Cryptography;

namespace AtCoder.D
{
    /// <summary>
    /// https://bplain.hatenablog.com/entry/2018/06/20/174128
    /// </summary>
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M) = Read2Longs();

            // なんでもあり
            if (M == 0) return "Yes";

            var people = new HashSet<long>();
            var G = new Dictionary<long, List<Info>>();
            for (int i = 0; i < M; i++)
            {
                var (l, r, d) = Read3Longs();
                if (!G.ContainsKey(l)) G.Add(l, new List<Info>());
                if (!G.ContainsKey(r)) G.Add(r, new List<Info>());
                G[l].Add(new Info { To = r, Dist = d });
                G[r].Add(new Info { To = l, Dist = -1 * d });
                people.Add(l);
                people.Add(r);
            }

            var peopleCoordinate = new long?[N + 1];

            while (people.Any())
            {
                // 一人目を適当に定め、位置 0 にいるものとする
                var firstPerson = people.First();
                people.Remove(firstPerson);
                peopleCoordinate[firstPerson] = 0;

                var queue = new Queue<Q>();
                foreach (var item in G[firstPerson])
                {
                    queue.Enqueue(new Q { From = firstPerson, Info = item });
                }
                while (queue.Count > 0)
                {
                    var q = queue.Dequeue();
                    people.Remove(q.Info.To);

                    // まだ座標が定まっていない場合
                    if (peopleCoordinate[q.Info.To] == null)
                    {
                        peopleCoordinate[q.Info.To] = peopleCoordinate[q.From] + q.Info.Dist;
                        foreach (var item in G[q.Info.To])
                        {
                            queue.Enqueue(new Q { From = q.Info.To, Info = item });
                        }

                        continue;
                    }

                    // 矛盾のチェック
                    if (peopleCoordinate[q.Info.To] != peopleCoordinate[q.From] + q.Info.Dist)
                    {
                        return "No";
                    }
                }
            }

            return "Yes";
        }

        class Info
        {
            public long To { get; set; }
            public long Dist { get; set; }
        }
        class Q
        {
            public long From { get; set; }
            public Info Info { get; set; }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 97048