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); }

        class Node
        {
            private readonly int m_num;
            private Node m_parent;
            private readonly List<Tuple<Node, long>> m_children;
            private Dictionary<int, long> m_distances;
            public Node(int num)
            {
                m_num = num;
                m_parent = this;
                m_children = new List<Tuple<Node, long>>();
                m_distances = new Dictionary<int, long>();
            }
            public static void Unite(Node a, Node b, long D)
            {
                a.m_children.Add(new Tuple<Node, long>(b, D));
                b.m_parent = a.m_parent;
            }
            public long Distance(int num)
            {
                if (m_num == num) { return 0; }
                if (m_distances.ContainsKey(num)) { return m_distances[num]; }
                long tmp = -1;
                foreach (var child in m_children)
                {
                    long d = child.Item1.Distance(num);
                    if (d >= 0)
                    {
                        tmp = child.Item2 + d;
                        break;
                    }
                }
                if (tmp != -1) { m_distances[num] = tmp; }
                return tmp;
            }
            public Node Parent()
            {
                return m_parent;
            }
        }

        static bool Solve(int N, int M, Tuple<int, int, int>[] tuples)
        {
            var nodes = new Node[N];
            for (int i = 0; i < N; ++i) { nodes[i] = new Node(i); }
            foreach (var tuple in tuples)
            {
                int L = tuple.Item1;
                int R = tuple.Item2;
                int D = tuple.Item3;
                var a = nodes[L].Parent();
                var b = nodes[R].Parent();
                long p = b.Distance(R);
                long q = a.Distance(L);
                if (a == b)
                {
                    if (p - q != D) { return false; }
                }
                else
                {
                    Node.Unite(a, b, q - p + D);
                }
            }
            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");
        }
    }
}
