#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int ar[100005][100005];
int main()
{
    int a,b,c;
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++)
    {
    	scanf("%d%d%d",&a,&b,&c);
        ar[a-1][b-1]=c;
        ar[b-1][a-1]=-c;
    }
    int yes=1;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
        	if (i==j)continue;
            for (int k=0;k<n;k++)
            {
            	if (ar[i][k]==0||ar[k][j]==0)continue;
                if (ar[i][j]!=0&&ar[i][j]!=ar[i][k]+ar[k][j])
                {
                    yes=0;
                    break;
                }
                ar[i][j]=ar[i][k]+ar[k][j];
            }
            if (yes==0)break;
        }
        if (yes==0)break;
    }
    if (yes==1)printf ("Yes\n");
    else printf ("No\n");
}
