#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// union - find tree !!!!!!!!!!!!!!!!!!!!!!!!!
vector<int> para(100005); //oya
vector<int> rnka(100005); //ki no hu ka sa
int D[100005][100005]; // 距離
// n要素で初期化
void init(int n){
    FOR(i, 0, n){para[i] = i;rnka[i] = 0;}
}
//木の根を求める
int find(int x){
    if(para[x] == x) return x;
    else return para[x] = find(para[x]);
}
//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnka[x] < rnka[y]) para[x] = y;
    else{para[y] = x;if(rnka[x] == rnka[y]) rnka[x]++;}
    return;
}
bool isSame(int x, int y){return find(x) == find(y);}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  bool ok = true;
  init(100005);
  FOR(i,0,M) {
    int l, r, d;
    cin >> l >> r >> d;
    if(D[r][l] > 0) ok = false;
    if(D[l][r] > 0) {
      if(D[l][r] != d) ok = false;
    } else {
      int p = find(l);
      if(D[p][r] == 0) {
        D[l][r] = d;
        D[p][r] = d + D[p][l];
      } else {
        if(D[p][l] + d != D[p][r]) ok = false;
      }
      unite(l, r);
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
}