using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC090
{
    public class Program
    {
        class LRD
        {
            public int L { get; }
            public int R { get; }
            public int D { get; }

            public LRD(int l, int r, int d)
            {
                if (l < r)
                {
                    L = l;
                    R = r;
                    D = d;
                }
                else
                {
                    L = r;
                    R = l;
                    D = -d;
                }
            }
        }

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(Int);
            var M = ss.Next(Int);
            var LRD = ss.Next(Int, 3, M)
                .Select(a => new LRD(a[0], a[1], a[2]))
                .OrderBy(lrd => lrd.L)
                .ThenBy(lrd => lrd.R);

            var dic = new Dictionary<int, int>();
            var res = true;
            foreach (var lrd in LRD)
            {
                var l = lrd.L;
                var r = lrd.R;
                var d = lrd.D;

                if (!dic.ContainsKey(l)) dic.Add(l, 0);

                if (dic.ContainsKey(r))
                {
                    if (dic[l] + d != dic[r])
                    {
                        res = false;
                        break;
                    }
                }
                else
                {
                    dic.Add(r, dic[l] + d);
                }
            }

            sw.WriteLine(res ? "Yes" : "No");
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;

        public static void Swap<T>(ref T left, ref T right)
        {
            var tmp = left;
            left = right;
            right = tmp;
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}