#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
bool vis[maxn], has[maxn], need[maxn];
int in[maxn], d[maxn], n, m;
set<int> Set;
struct Edge {
  int from, to, dist;
};
vector<Edge> edges;
vector<int> G[maxn];
void addedge(int u, int v, int w) {
  edges.push_back((Edge){u, v, w});
  G[u].push_back(edges.size() - 1);
  edges.push_back((Edge){v, u, -w});
  G[v].push_back(edges.size() - 1);
}
bool spfa(int x) {
  queue<int> q;
  q.push(x);
  vis[x] = true;
  has[x] = true;
  d[x] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = false;
    for (int i = 0; i < G[u].size(); i++) {
      Edge& e = edges[G[u][i]];
      int to = e.to;
      int dist = e.dist;
      has[to] = true;
      if (d[u] + dist < d[to]) {
        d[to] = d[u] + dist;
        if (!vis[to]) {
          if (++in[to] > n) return false;
          vis[to] = true;
          q.push(to);
        }
      }
    }
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    d[i] = 1100000000;
    G[i].clear();
  }
  memset(vis, false, sizeof(vis));
  memset(in, 0, sizeof(in));
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    need[u] = need[v] = true;
    addedge(u, v, w);
  }
  for (int i = 1; i <= n; i++) {
    if (!need[i]) continue;
    if (!spfa(i)) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
