#include <bits/stdc++.h>
using namespace std;
const int N = 500001;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
using namespace std;
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int min(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int inf = 100000000000000000;
vector<pair<int, int> > adj[N];
vector<int> topo;
class Graph {
  int V;
  list<int>* adj;

 public:
  Graph(int V);
  void addEdge(int u, int v);
  void topologicalSort();
};
Graph::Graph(int V) {
  this->V = V;
  adj = new list<int>[V];
}
void Graph::addEdge(int u, int v) { adj[u].push_back(v); }
int cycle = 0;
void Graph::topologicalSort() {
  vector<int> in_degree(V, 0);
  for (int u = 0; u < V; u++) {
    list<int>::iterator itr;
    for (itr = adj[u].begin(); itr != adj[u].end(); itr++) in_degree[*itr]++;
  }
  queue<int> q;
  for (int i = 0; i < V; i++)
    if (in_degree[i] == 0) q.push(i);
  int cnt = 0;
  vector<int> top_order;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    top_order.push_back(u);
    list<int>::iterator itr;
    for (itr = adj[u].begin(); itr != adj[u].end(); itr++)
      if (--in_degree[*itr] == 0) q.push(*itr);
    cnt++;
  }
  if (cnt != V) {
    cycle = 1;
    return;
  }
  for (int i = 0; i < top_order.size(); i++) topo.push_back(top_order[i]);
}
void solve() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  int left[m], right[m], dist[m];
  for (long long int i = 0; i < m; i++) {
    cin >> left[i] >> right[i] >> dist[i];
    g.addEdge(left[i] - 1, right[i] - 1);
    adj[left[i] - 1].push_back(make_pair(right[i] - 1, dist[i]));
  }
  g.topologicalSort();
  if (cycle) {
    cout << "No" << '\n';
    return;
  }
  int pos[n];
  for (long long int i = 0; i < n; i++) pos[i] = -1;
  for (auto x : topo) {
    if (pos[x] == -1) pos[x] = 0;
    for (auto i : adj[x]) {
      if (pos[i.first] == -1)
        pos[i.first] = pos[x] + i.second;
      else if (pos[x] + i.second != pos[i.first]) {
        cout << "No" << '\n';
      }
    }
  }
  cout << "Yes" << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  int t = 0;
  while (t++ < T) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
