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;
        long D = 0;
        Node[] node = new Node[N];
        UnionFind UF = new UnionFind(N);
        for (int i = 0; i < N; i++) { node[i] = new Node(i); node[i].cost = INFINITY; }
        for (int i = 0; i < M; i++)
        {
            L = NextInt() - 1;
            R = NextInt() - 1;
            D = NextLong();
            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);
            UF.Unite(R, L);
        }
        Queue<int> Q = new Queue<int>();
        HashSet<int> p = new HashSet<int>();
        for (int i = 0; i < N; i++)
        {
            if (!p.Contains(UF.Root(i))) p.Add(UF.Root(i));
        }
        foreach (var i in p) { Q.Enqueue(i); node[i].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 == INFINITY)
                {
                    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 UnionFind
{
    public List<int> parent = new List<int>();

    public UnionFind(int N)
    {
        for (int i = 0; i < N; i++) parent.Add(i);
    }

    public int Root(int a)
    {
        if (parent[a] == a) return a;
        else return parent[a] = Root(parent[a]);
    }

    public void Unite(int a, int b)
    {
        a = Root(a);
        b = Root(b);
        if (a == b) return;
        parent[a] = parent[b];
    }

    public bool Same(int a, int b) { return (Root(a) == Root(b)); }
}

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


Measured memory_bytes: 50284