#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, d;
};
struct Node {
  int x, point;
};
int points[100000];
bool validate(vector<Edge> es[], int n) {
  fill(points, points + n, 1000000007);
  while (true) {
    queue<Node> que;
    int start = 0;
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (es[i].size() && points[i] == 1000000007) {
        start = i;
        break;
      }
    }
    if (flag) {
      return true;
    }
    que.push(Node{start, 0});
    while (!que.empty()) {
      Node p = que.front();
      que.pop();
      if (points[p.x] < 1000000007) {
        if (p.point != points[p.x]) return false;
      } else {
        points[p.x] = p.point;
        for (auto e : es[p.x]) {
          que.push(Node{e.to, e.d + p.point});
        }
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<Edge> es[n];
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    es[l].push_back(Edge{r, d});
    es[r].push_back(Edge{l, -d});
  }
  cout << ((validate(es, n)) ? "Yes" : "No") << endl;
  return 0;
}
