#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
int M;
int L[MMAX];
int R[MMAX];
int D[MMAX];
int x[NMAX];
vector<pair<int, int> > graph[NMAX];
vector<int> topSort;
bool vis[NMAX];
void dfs(int node) {
  vis[node] = true;
  for (auto it : graph[node])
    if (!vis[it.first]) dfs(it.first);
  topSort.push_back(node);
}
int where[NMAX];
void dfs2(int node) {
  vis[node] = true;
  for (auto it : graph[node])
    if (!vis[it.first]) {
      x[it.first] = it.second + x[node];
      dfs2(it.first);
    }
}
int main() {
  int N;
  cin >> N >> M;
  for (int i = 1; i <= M; ++i) {
    cin >> L[i] >> R[i] >> D[i];
    graph[L[i]].push_back({R[i], D[i]});
  }
  for (int i = 1; i <= N; ++i)
    if (!vis[i]) dfs(i);
  reverse(topSort.begin(), topSort.end());
  for (int i = 0; i < topSort.size(); ++i) where[topSort[i]] = i;
  bool fail = false;
  for (int i = 1; i <= M; ++i)
    if (where[L[i]] > where[R[i]]) {
      fail = true;
      break;
    }
  if (fail) {
    cout << "No\n";
    return 0;
  }
  for (int i = 1; i <= M; ++i) graph[R[i]].push_back({L[i], -D[i]});
  for (int i = 1; i <= N; ++i) vis[i] = false;
  for (int i = 1; i <= N; ++i)
    if (!vis[i]) dfs2(i);
  for (int i = 1; i <= M; ++i)
    if (x[L[i]] + D[i] != x[R[i]]) {
      fail = true;
      break;
    }
  if (fail) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}
