using System;
class Program
{

static string[] input = Console.ReadLine().Split(' ');
static int n = int.Parse(input[0]);
static int m = int.Parse(input[1]);
static int[,] parents = new int[n,2];//親と、親から右への距離
static bool answer = true;
  
	static void Main()
	{
    for(int i = 1; i < n; i++)
    {
    parents[i,0] = i;
    parents[i,1] = 0;
    }
    
    for(int i = 0; i < m; i++)
    {
    int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

      if(whatParent(nums[0]) == whatParent(nums[1]))
      {
        if(parents[nums[1], 1] - parents[nums[0], 1] != nums[2]) answer = false;
          //グループ内の距離が矛盾でfalse
      }
      else
      {
         parents[nums[0], 0] = whatParent(nums[1]);//親の統一
         parents[nums[0], 1] = parents[nums[1], 1] - nums[2];//親との距離
      }
    }

    Console.WriteLine((answer) ? "Yes" : "No");
    
	}

  static int whatParent(int child)
  {
    if(parents[child,0] == child) return child;
    else return child = whatParent(parents[child,0]);
  }
  
}