#include <bits/stdc++.h>
using namespace std;
struct bian {
  int x, to, next;
} edge[400001];
int cnt, head[100001], dis[100001];
bool vis[100001], f;
inline void add(int u, int v, int x) {
  edge[cnt].x = x, edge[cnt].to = v, edge[cnt].next = head[u], head[u] = cnt++;
}
inline void dfs(int x) {
  for (int i = head[x]; i; i = edge[i].next) {
    if (!vis[edge[i].to]) {
      vis[edge[i].to] = 1;
      dis[edge[i].to] = dis[x] + edge[i].x;
      dfs(edge[i].to);
    } else if (dis[edge[i].to] != dis[x] + edge[i].x) {
      f = 0;
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    add(l, r, -d), add(r, l, d);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      f = 1;
      dfs(i);
      if (!f || dis[i] != 0) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
