#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> distances;
pair<int, int> input;
int visited[1000005];
vector<int> picture[100005];
int dfs(int x, int y, int deep);
int main() {
  bool check = true;
  int numbers;
  int pairs;
  cin >> numbers >> pairs;
  for (int i = 0; i < pairs; i++) {
    int b, e, d;
    cin >> input.first >> input.second;
    cin >> d;
    if (distances[input] == 0) {
      memset(visited, 0, sizeof(visited));
      distances[input] = dfs(input.first, input.second, 0);
      distances[make_pair(input.second, input.first)] = distances[input];
    }
    picture[input.first].push_back(input.second);
    picture[input.second].push_back(input.first);
    if (check) {
      if (distances[input] != 0) {
        if (distances[input] != d) {
          cout << "No\n";
          check = false;
        }
      } else {
        distances[input] = d;
        distances[make_pair(input.second, input.first)] = 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 distances[make_pair(x, picture[x][i])] + deep;
    }
    value =
        dfs(picture[x][i], y, deep + distances[make_pair(x, picture[x][i])]);
    if (value != 0) {
      return value;
    }
  }
  return 0;
}
