#include <bits/stdc++.h>
struct Edge {
  int l, r;
  long long c;
  Edge(int l, int r, long long c) : l(l), r(r), c(c) {}
};
std::vector<Edge> g[100005];
int vis[100005];
long long value[100005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int l, r;
    long long c;
    scanf("%d%d%lld", &l, &r, &c);
    g[l].push_back(Edge(l, r, c));
  }
  value[1] = 1;
  vis[1] = 0;
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      if (g[i].size() == 0) continue;
      for (Edge edge : g[i]) {
        int v = edge.r;
        if (vis[v]) {
          if (vis[i]) {
            if (value[i] + edge.c != value[v]) ok = 0;
          } else {
            vis[i] = 1;
            value[i] = value[v] - edge.c;
          }
        }
      }
    }
    if (!vis[i]) vis[i] = 1, value[i] = 0;
    for (Edge edge : g[i]) {
      int v = edge.r;
      if (vis[v]) {
        if (value[i] + edge.c != value[v]) ok = 0;
      } else {
        vis[v] = 1;
        value[v] = value[i] + edge.c;
      }
    }
  }
  if (ok)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
