#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<long long>> dis(N + 1, vector<long long>(N + 1, INT64_MAX));
  vector<vector<int>> neighbor(N + 1, vector<int>());
  for (int i = 1; i <= N; i++) {
    dis[i][i] = 0;
    neighbor[i].push_back(i);
  }
  for (int i = 0; i < M; i++) {
    int lx, rx, dx;
    cin >> lx >> rx >> dx;
    for (int j = 0; j < neighbor[lx].size(); j++) {
      if (dis[rx][neighbor[lx][j]] != INT64_MAX) {
        if (dis[rx][neighbor[lx][j]] != dis[lx][neighbor[lx][j]] - dx) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        dis[rx][neighbor[lx][j]] = dis[lx][neighbor[lx][j]] - dx;
        dis[neighbor[lx][j]][rx] = 0 - dis[rx][neighbor[lx][j]];
        neighbor[rx].push_back(neighbor[lx][j]);
        neighbor[neighbor[lx][j]].push_back(rx);
      }
    }
    for (int j = 0; j < neighbor[rx].size(); j++) {
      if (dis[lx][neighbor[rx][j]] != INT64_MAX) {
        if (dis[lx][neighbor[rx][j]] != dis[rx][neighbor[rx][j]] + dx) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        dis[lx][neighbor[rx][j]] = dis[rx][neighbor[rx][j]] + dx;
        dis[neighbor[rx][j]][lx] = 0 - dis[lx][neighbor[rx][j]];
        neighbor[lx].push_back(neighbor[rx][j]);
        neighbor[neighbor[rx][j]].push_back(lx);
      }
    }
  }
  cout << "Yes" << endl;
}
