#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M;
class Edge {
 public:
  map<int, int> __;
};
vector<Edge> E;
void show() {
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      auto itr = E[i].__.find(j);
      if (itr != E[i].__.end()) {
        printf("%2d ", E[i].__[j]);
      } else {
        cout << ".. ";
      }
    }
    cout << endl;
  }
  cout << endl;
}
int main() {
  cin >> N >> M;
  E = vector<Edge>(N + 1);
  for (int i = 0; i < M; ++i) {
    int L, R, D;
    cin >> L >> R >> D;
    queue<int> OpenList;
    map<int, bool> CloseList;
    OpenList.push(L);
    while (!OpenList.empty()) {
      int V = OpenList.front();
      CloseList[V] = true;
      OpenList.pop();
      for (auto itr = E[V].__.begin(); itr != E[V].__.end(); ++itr) {
        int U = itr->first;
        auto c = CloseList.find(U);
        if (c != CloseList.end()) {
          continue;
        }
        CloseList[U] == true;
        OpenList.push(U);
        E[L].__[U] = E[L].__[V] + E[V].__[U];
        if (U == R && E[L].__[R] != D) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
    E[L].__[R] = D;
    E[R].__[L] = -D;
  }
  cout << "Yes" << endl;
  return 0;
}
