#include <bits/stdc++.h>

using namespace std;

const int Nmax = int(1e5 + 2);
int n, m, val[Nmax];
bool vis[Nmax];
vector<pair<int, int>>G[Nmax];
void dfs(int x) {
   vis[x] = 1;
   for(auto it : G[x]) {
      int y = it.first, cost = it.second;
      if(!vis[y]) {
         val[y] = val[x] + cost;
         dfs(y);
      } else if(val[y] != val[x] + cost) {
         cout << "No";
         exit(0);
      }
   }
}
int32_t main() {
  //ifstream cin("a.in");
   cin >> n >> m;
   for(int i = 1; i <= m; ++i) {
      int l, r, c;
      cin >> l >> r >> c;
      G[l].emplace_back(r, c);
      G[r].emplace_back(l, -c);
   }
   for(int i = 1; i <= n; ++i)
      if(!vis[i]) dfs(i);
   cout << "Yes";
}

