#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
long long INF = 1LL << 60;
struct Node {
  int pos;
  long long dis;
  Node() {}
  Node(int p, long long d) {
    pos = p;
    dis = d;
  }
};
int n, m;
long long num[maxn];
int deg[maxn];
vector<Node> G[maxn];
int l[maxn], r[maxn];
long long d[maxn];
queue<int> que;
int fa[maxn];
void Init() {
  for (int i = 1; i <= n; ++i) {
    fa[i] = i;
    G[i].clear();
  }
  fill(num, num + n + 1, INF);
}
int Find(int x) { return (x == fa[x] ? x : fa[x] = Find(fa[x])); }
void unit(int x, int y) {
  int xx = Find(x);
  int yy = Find(y);
  fa[xx] = yy;
}
void bfs() {
  for (int i = 1; i <= n; ++i) {
    num[Find(i)] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (num[i] == 0) {
      que.push(i);
    }
  }
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    int len = G[x].size();
    for (int i = 0; i < len; ++i) {
      int pos = G[x][i].pos;
      long long dis = G[x][i].dis;
      if (num[pos] == INF) {
        num[pos] = num[x] + dis;
        que.push(pos);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d%d", &n, &m) != EOF) {
    Init();
    for (int i = 0; i < m; ++i) {
      scanf("%d%d%I64d", &l[i], &r[i], &d[i]);
      unit(l[i], r[i]);
      G[l[i]].push_back(Node(r[i], d[i]));
      G[r[i]].push_back(Node(l[i], -d[i]));
    }
    bfs();
    bool flag = true;
    for (int i = 0; i < m; ++i) {
      if (num[r[i]] - num[l[i]] != d[i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
