#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
struct edge {
  int to, cost;
};
vector<edge> G[MAX_N];
bool flag[MAX_N];
int d[MAX_N];
bool dfs(int u, int dist) {
  d[u] = dist;
  flag[u] = true;
  for (auto v : G[u]) {
    if (!flag[v.to]) {
      if (dfs(v.to, dist + v.cost)) {
        return true;
      }
    } else {
      if (d[v.to] != dist + v.cost) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a - 1].push_back((edge){b - 1, c});
  }
  for (int i = 0; i < (int)(m); ++i) {
    if (!flag[i] && (int)(G[i]).size()) {
      if (dfs(i, 0)) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
