using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087_D
{
    class Program
    {
        class Node
        {
            public int Parent;
            public int Position;

            public Node(int parent, int position)
            {
                Parent = parent;
                Position = position;
            }
        }


        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int n = int.Parse(strs[0]);
            int m = int.Parse(strs[1]);

            bool flag = true;


            Node[] position = new Node[n + 1];
            Queue<int>[] axis = new Queue<int>[n + 1];

            for (int i = 0; i < m; ++i)
            {
                string[] strs2 = Console.ReadLine().Split(' ');
                int l = int.Parse(strs2[0]);
                int r = int.Parse(strs2[1]);
                int d = int.Parse(strs2[2]);

#if true
                if (l > r)
                {
                    int tmp = l;
                    l = r;
                    r = tmp;
                    d = -d;
                }
#endif


                if (position[l] == null)
                {
                    if (position[r] == null)
                    {
                        position[l] = new Node(l, 0);

                        position[r] = new Node(l, d);
                        axis[l] = new Queue<int>();
                        axis[l].Enqueue(l);
                        axis[l].Enqueue(r);
                    }
                    else
                    {
                        int rParent = position[r].Parent;
                        int rPosition = position[r].Position;

                        axis[rParent].Enqueue(l);

                        if (l < rParent)
                        {
                            position[l] = new Node(l, rPosition - d);
                            foreach(int index in axis[rParent])
                            {
                                position[index].Parent = l;
                            }
                            axis[l] = axis[rParent];
                            axis[rParent] = null;
                        }
                        else
                        {
                            position[l] = new Node(rParent, rPosition - d);
                        }
                    }
                }
                else
                {
                    int lParent = position[l].Parent;
                    int lPosition = position[l].Position;

                    // lの人が既に登録されていたら
                    if (position[r] == null)
                    {
                        position[r] = new Node(lParent, lPosition + d);
                        axis[lParent].Enqueue(r);
                    }
                    else
                    {
                        int rParent = position[r].Parent;
                        int rPosition = position[r].Position;

                        // lの人もrの人も既に登録されていたら
                        if (lParent == rParent)
                        {
                            // lとrの総親が同じな場合、座標が食い違っていないかを確認する
                            if (rPosition - lPosition != d)
                            {
                                flag = false;
                                break;
                            }
                        }
                        else
                        {
                            // lとrの総親が異なる場合、座標系を合体させる
                            // 子供が少ないほうの総親の子供の情報を書き換える
                            Queue<int> src;
                            Queue<int> dst;
                            int parent;
                            int diffPosition;
                            //if (axis[lParent].Count < axis[rParent].Count)
                            if (rParent < lParent)
                            {
                                dst = axis[lParent];
                                src = axis[rParent];
                                axis[lParent] = null;
                                parent = rParent;
                                diffPosition = (rPosition - d) - lPosition;
                            }
                            else
                            {
                                dst = axis[rParent];
                                src = axis[lParent];
                                axis[rParent] = null;
                                parent = lParent;
                                diffPosition = (lPosition + d) - rPosition;
                            }

                            foreach (int index in dst)
                            {
                                position[index].Parent = parent;
                                position[index].Position += diffPosition;

                                src.Enqueue(index);
                            }

                            //src.Concat(dst);

                        //必要？
                            //dst.Clear();
                        }

                    }
                }
            }

            Console.WriteLine("{0}", flag ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 31160