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

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

struct S
{
    public int R, D;
    public S(int r, int d)
    {
        R = r;
        D = d;
    }
}

class Program
{
    private int N;
    private int M;
    private int[] L, R, D;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        L = new int[M];
        R = new int[M];
        D = new int[M];
        for (int i = 0; i < M; i++)
        {
            L[i] = sc.NextInt() - 1;
            R[i] = sc.NextInt() - 1;
            D[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        Scan();
        var list = new List<S>[N];
        for (int i = 0; i < N; i++)
        {
            list[i] = new List<S>();
        }
        for (int i = 0; i < M; i++)
        {
            list[L[i]].Add(new S(R[i], D[i]));
            list[R[i]].Add(new S(L[i], -D[i]));
        }
        var pos = (new long[N]).Select(i => long.MinValue).ToArray();
        pos[0] = 0;
        for (int i = 0; i < N; i++)
        {
            foreach (var s in list[i])
            {
                if (pos[s.R] == long.MinValue)
                {
                    pos[s.R] = pos[i] + s.D;
                }
                else
                {
                    if (pos[s.R] != pos[i] + s.D)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
        }
        Console.WriteLine("Yes");
    }

    static public void Main()
    {
        new Program().Solve();
    }
}