#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m;
bool vis[maxn];
map<int, int> MAP;
struct Edge {
  int to, d;
  Edge(int _to, int _d) : to(_to), d(_d) {}
};
vector<Edge> G[maxn];
void AddEdge(int u, int v, int d) {
  G[u].push_back(Edge(v, -d));
  G[v].push_back(Edge(u, d));
}
bool dfs(int x) {
  vis[x] = true;
  if (MAP.count(x) == 0) MAP[x] = 0;
  for (int i = 0; i < G[x].size(); i++) {
    Edge &e = G[x][i];
    if (MAP.count(e.to) == 0) MAP[e.to] = MAP[x] - e.d;
    if (MAP[x] - MAP[e.to] != e.d) return false;
    if (!vis[x] && !dfs(e.to)) return false;
  }
  return true;
}
int main() {
  int l, r, d;
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &l, &r, &d);
    AddEdge(l, r, d);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfs(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
