#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
int d[100010], d_rev[100010], n, m;
vector<edge> normal_graph[100010], reverse_graph[100010];
bitset<100010> normal_vaz, reverse_vaz;
bool bfs(int start, bool reverse) {
  queue<int> q;
  bitset<100010> vaz_local;
  if (reverse) {
    reverse_vaz[start] = true;
    vaz_local[start] = true;
    d_rev[start] = 0;
  } else {
    normal_vaz[start] = true;
    vaz_local[start] = true;
    d[start] = 0;
  }
  q.push(start);
  while (!q.empty()) {
    int current = q.front();
    q.pop();
    if (!reverse) {
      int directions = normal_graph[current].size() - 1;
      for (int i = directions; i >= 0; --i, normal_graph[current].pop_back()) {
        if (!vaz_local[normal_graph[current][i].to]) {
          vaz_local[normal_graph[current][i].to] = true;
          normal_vaz[normal_graph[current][i].to] = true;
          d[normal_graph[current][i].to] =
              d[current] + normal_graph[current][i].cost;
        } else if (d[normal_graph[current][i].to] !=
                   d[current] + normal_graph[current][i].cost) {
          return false;
        }
        q.push(normal_graph[current][i].to);
      }
    } else {
      int directions = reverse_graph[current].size() - 1;
      for (int i = directions; i >= 0; --i, reverse_graph[current].pop_back()) {
        if (!vaz_local[reverse_graph[current][i].to]) {
          vaz_local[reverse_graph[current][i].to] = true;
          reverse_vaz[reverse_graph[current][i].to] = true;
          d_rev[reverse_graph[current][i].to] =
              d_rev[current] + reverse_graph[current][i].cost;
        } else if (d_rev[reverse_graph[current][i].to] !=
                   d_rev[current] + reverse_graph[current][i].cost) {
          return false;
        }
        q.push(reverse_graph[current][i].to);
      }
    }
  }
  return true;
}
int main() {
  int l, r, c;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> c;
    normal_graph[l].push_back({r, c});
    reverse_graph[r].push_back({l, c});
  }
  if (m) {
    for (int i = 1; i <= n; ++i) {
      if (!normal_vaz[i])
        if (!bfs(i, false)) {
          cout << "No";
          return 0;
        }
      if (!reverse_vaz[i])
        if (!bfs(i, true)) {
          cout << "No";
          return 0;
        }
    }
    cout << "Yes";
  } else {
    cout << "Yes";
  }
  return 0;
}
