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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(int N, int M, Tuple<int, int, int>[] tuples)
        {
            var trees = new List<Dictionary<int, long>>();
            foreach (var tuple in tuples)
            {
                int L = tuple.Item1;
                int R = tuple.Item2;
                int D = tuple.Item3;
                var tree1 = trees.FirstOrDefault(tree => tree.ContainsKey(L));
                var tree2 = trees.FirstOrDefault(tree => tree.ContainsKey(R));
                if (tree1 == tree2)
                {
                    if (tree1 == null)
                    {
                        var dic = new Dictionary<int, long>();
                        dic[L] = 0;
                        dic[R] = D;
                        trees.Add(dic);
                    }
                    else
                    {
                        if (tree2[R] - tree1[L] != D) { return false; }
                    }
                }
                else
                {
                    if (tree1 == null)
                    {
                        tree2[L] = tree2[R] - D;
                    }
                    else if (tree2 == null)
                    {
                        tree1[R] = tree1[L] + D;
                    }
                    else
                    {
                        long offset = tree1[L] - tree2[R] + D;
                        foreach (var pair in tree2)
                        {
                            tree1[pair.Key] = tree2[pair.Key] + offset;
                        }
                        trees.Remove(tree2);
                    }
                }
            }
            return true;
        }

        static void Main(string[] args)
        {
            int[] values1 = ReadInts();
            int N = values1[0];
            int M = values1[1];
            var tuples = new Tuple<int, int, int>[M];
            for (int i = 0; i < M; ++i)
            {
                int[] values2 = ReadInts();
                tuples[i] = new Tuple<int, int, int>(values2[0] - 1, values2[1] - 1, values2[2]);
            }
            Console.WriteLine(Solve(N, M, tuples) ? "Yes" : "No");
        }
    }
}
