using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; public Pair(int xx, int yy) { x = xx; y = yy; } }
    private static int[] dx = { 1, 0, -1, 0 };
    private static int[] dy = { 0, -1, 0, 1 };
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        int L = 0, R, D;
        Node[] node = new Node[N];
        for (int i = 0; i < N; i++) { node[i] = new Node(i); node[i].cost = INF; }
        for (int i = 0; i < M; i++)
        {
            L = NextInt() - 1;
            R = NextInt() - 1;
            D = NextInt();
            Edge e = new Edge();
            e.to = R;
            e.cost = D;
            node[L].to.Add(e);
            e = new Edge();
            e.to = L;
            e.cost = -D;
            node[R].to.Add(e);
        }
        Queue<int> Q = new Queue<int>();
        Q.Enqueue(L);
        node[L].cost = 0;
        while (Q.Count() != 0)
        {
            int now = Q.Dequeue();
            foreach (var i in node[now].to)
            {
                //Console.WriteLine((now+1) + " " + (i.to+1));
                if (node[i.to].cost == INF)
                {
                    node[i.to].cost = node[now].cost + i.cost;
                    Q.Enqueue(i.to);
                }
                else
                {
                    if (node[now].cost + i.cost != node[i.to].cost) {
                        
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
        }

        Console.WriteLine("Yes");
    }
}


public class Node
{
    public List<Edge> to = new List<Edge>();
    public int name = 0;
    public bool visit = false;
    public long cost = 0;
    public Node(int name) { this.name = name; }
}
public class Edge
{
    public int to;
    public long cost;
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}
