#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<unordered_map<int, int>> s(N), t(N);
  vector<int> L(M), R(M), D(M);
  UnionFind u(N);
  vector<vector<int>> g(N);
  vector<bool> visited(N, false);
  for (int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i] >> D[i];
    --L[i];
    --R[i];
    if (L[i] < R[i]) {
      g[L[i]].push_back(R[i]);
    } else {
      g[R[i]].push_back(-L[i]);
    }
    s[L[i]].emplace(R[i], D[i]);
    t[R[i]].emplace(L[i], D[i]);
    u.unite(L[i], R[i]);
  }
  set<int> root;
  for (int i = 0; i < N; ++i) {
    root.insert(u.root(i));
  }
  for (int r : root) {
    vector<long long> pos(N, LLONG_MIN);
    set<int> waiting;
    waiting.insert(r);
    pos[r] = 0;
    while (!waiting.empty()) {
      int x = *waiting.begin();
      if (!s[x].empty()) {
        int y = s[x].begin()->first;
        int d = s[x].begin()->second;
        s[x].erase(y);
        t[y].erase(x);
        if (pos[y] == LLONG_MIN) {
          pos[y] = pos[x] + d;
        } else if (pos[y] != pos[x] + d) {
          cout << "No" << endl;
          return 0;
        }
        waiting.insert(y);
      } else if (!t[x].empty()) {
        int y = t[x].begin()->first;
        int d = t[x].begin()->second;
        s[y].erase(x);
        t[x].erase(y);
        if (pos[y] == LLONG_MIN) {
          pos[y] = pos[x] - d;
        } else if (pos[y] != pos[x] - d) {
          cout << "No" << endl;
          return 0;
        }
        waiting.insert(y);
      } else {
        waiting.erase(x);
      }
    }
  }
  cout << "Yes" << endl;
}
