using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace ABC087D
{
    class Program
    {
        static void Solve()
        {
            var n = Input.NextInt();
            var m = Input.NextInt();

            var uf = new WeightedUnionFind(n);
            var answer = "Yes";
            foreach (var _ in Enumerable.Range(0, m))
            {
                var l = Input.NextInt() - 1;
                var r = Input.NextInt() - 1;
                var d = Input.NextInt();

                if (uf.Same(l, r))
                {
                    var diff = uf.Diff(l, r);
                    if (diff != d)
                    {
                        answer = "No";
                        break;
                    }
                }
                else
                {
                    uf.Merge(l, r, d);
                }
            }

            Console.WriteLine(answer);
        }

        /// <summary>
        /// アイテムを含まない 重み付きUF木
        /// </summary>
        class WeightedUnionFind
        {
            public List<int> ParentId { get; set; }
            public List<int> Rank { get; set; }
            public List<long> DiffWeight { get; set; }

            public WeightedUnionFind(int size)
            {
                this.ParentId = Enumerable.Range(0, size).ToList();
                this.Rank = Enumerable.Repeat(0, size).ToList();
                this.DiffWeight = Enumerable.Repeat(0L, size).ToList();
            }

            /// <summary>
            /// 同一の親を持つか
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <returns></returns>
            public bool Same(int x, int y)
            {
                return FindRoot(x) == FindRoot(y);
            }

            /// <summary>
            /// 指定ノードのrootを返す
            /// </summary>
            /// <param name="x"></param>
            /// <returns></returns>
            public int FindRoot(int x)
            {
                if (x != this.ParentId[x])
                {
                    // 経路中のノードのパラメータを更新しておく
                    var root = FindRoot(this.ParentId[x]);
                    this.DiffWeight[x] += this.DiffWeight[this.ParentId[x]];
                    this.ParentId[x] = root;
                }

                return this.ParentId[x];
            }

            /// <summary>
            /// 親経路との重さを返す
            /// </summary>
            /// <param name="x"></param>
            /// <returns></returns>
            public long Weight(int x)
            {
                FindRoot(x);

                return this.DiffWeight[x];
            }

            /// <summary>
            /// x,yが同一の親を持つ場合、Weightの差分（y-x）を返す
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <returns></returns>
            public long Diff(int x, int y)
            {
                return Weight(y) - Weight(x);
            }

            /// <summary>
            /// 重みをつけて合体する
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <param name="w"></param>
            public void Merge(int x, int y, long w)
            {
                w += Weight(x) - Weight(y);

                x = FindRoot(x);
                y = FindRoot(y);

                if (x == y) return;

                if (this.Rank[x] < this.Rank[y])
                {
                    this.ParentId[x] = y;
                    this.DiffWeight[x] = -w;
                }
                else
                {
                    this.ParentId[y] = x;
                    this.DiffWeight[y] = w;

                    if (this.Rank[x] == this.Rank[y]) this.Rank[x]++;
                }
            }
        }

        #region Competitive Template
        public static void Main(string[] args)
        {
            var needsFlushOutput = true;
            if (needsFlushOutput)
            {
                // 細かく出力しないようにする
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
            }

            // 仮想的に標準入力をセットする
            // NextLine系を使っていると使えない
            //Input.SetText("");

            Solve();

            Console.Out.Flush();
        }

        static class Input
        {
            static char[] separator = { ' ' };
            public static bool IsEof { get; set; }
            static Queue<string> q { get; set; }

            static Input()
            {
                IsEof = false;
                q = new Queue<string>();
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="items"></param>
            public static void SetText(IEnumerable<string> items)
            {
                foreach (var item in items)
                {
                    SetText(item);
                }
            }

            /// <summary>
            /// 入力予約
            /// </summary>
            /// <param name="s"></param>
            /// <returns></returns>
            public static bool SetText(string s)
            {
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                return true;
            }

            /// <summary>
            /// 内部queueに入力からの値をsplitして格納する
            /// </summary>
            /// <returns></returns>
            static bool read()
            {
                var s = Console.ReadLine();
                if (s == null) return false;

                foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries))
                {
                    q.Enqueue(elem);
                }

                if (!q.Any()) return read();

                return true;
            }

            /// <summary>
            /// 次のstringを一つ読み込む
            /// </summary>
            /// <returns></returns>
            public static string Next()
            {
                if (!q.Any())
                {
                    if (!read())
                    {
                        IsEof = true;
                        return "";
                    }
                }

                return q.Dequeue();
            }

            public static int NextInt() => int.Parse(Next());
            public static long NextLong() => long.Parse(Next());
            public static double NextDouble() => double.Parse(Next());

            public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
            public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
            public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
            public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();

            public static List<string> NextLine() => Console.ReadLine().Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();
            public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
            public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
            public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
        }
        #endregion
    }
}


Measured memory_bytes: 21344