#include <bits/stdc++.h>
using namespace std;
int dp[5000][5000];
int visited[5000];
vector<int> picture[5000];
int dfs(int x, int y, int deep);
int main() {
  bool check = true;
  int numbers;
  int pairs;
  cin >> numbers >> pairs;
  for (int i = 1; i <= numbers; i++) {
    for (int j = 1; j <= numbers; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 0; i < pairs; i++) {
    int b, e, d;
    cin >> b >> e;
    cin >> d;
    if (dp[b][e] == 0) {
      memset(visited, 0, sizeof(visited));
      dp[b][e] = dfs(b, e, 0);
      dp[e][b] = dp[b][e];
    }
    picture[b].push_back(e);
    picture[e].push_back(b);
    if (check) {
      if (dp[b][e] != 0) {
        if (dp[b][e] != d) {
          cout << "No\n";
          check = false;
        }
      } else {
        dp[b][e] = d;
        dp[e][b] = d;
      }
    }
  }
  if (check) {
    cout << "Yes\n";
  }
  return 0;
}
int dfs(int x, int y, int deep) {
  int value = 0;
  if (visited[x] == 1) {
    return 0;
  }
  visited[x] = 1;
  for (int i = 0; i < picture[x].size(); i++) {
    if (picture[x][i] == y) {
      return dp[x][picture[x][i]] + deep;
    }
    value = dfs(picture[x][i], y, deep + dp[x][picture[x][i]]);
    if (value != 0) {
      return value;
    }
  }
  return 0;
}
